2015-09-01 28 views
0

Sir Sir 我試圖從C#中的app.manifest中獲得10的勝利,但它似乎不工作。從app.manifest C#靶向贏得10#

app.manifest

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 

<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <assemblyIdentity version="1.0.0.0" name="MyApplication.app" /> 

    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <security> 
     <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> 
     <!-- UAC Manifest Options 
      If you want to change the Windows User Account Control level replace the 
      requestedExecutionLevel node with one of the following. 

     <requestedExecutionLevel level="asInvoker" uiAccess="false" /> 
     <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 
     <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> 

      Specifying requestedExecutionLevel element will disable file and registry virtualization. 
      Remove this element if your application requires this virtualization for backwards 
      compatibility. 
     --> 
     <requestedExecutionLevel level="highestAvailable" uiAccess="true" /> 
     </requestedPrivileges> 
    </security> 
    </trustInfo> 

    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
     <!-- A list of the Windows versions that this application has been tested on and is 
      is designed to work with. Uncomment the appropriate elements and Windows will 
      automatically selected the most compatible environment. --> 

     <!-- Windows 10 --> 
     <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> 

     <!-- Windows 8.1 --> 
     <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" /> 

     <!-- Windows 8 --> 
     <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" /> 

     <!-- Windows 7 --> 
     <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" /> 

     <!-- Windows Vista --> 
     <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" /> 
    </application> 
    </compatibility> 
    <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> 

    <dependency> 
    <dependentAssembly> 
     <assemblyIdentity 
     type="win32" 
     name="Microsoft.Windows.Common-Controls" 
     version="6.0.0.0" 
     processorArchitecture="*" 
     publicKeyToken="6595b64144ccf1df" 
     language="*" /> 
    </dependentAssembly> 
    </dependency> 
</assembly> 

的Environment.OSVersion.Version返回仍然是V6.2。

另外,我想知道在哪裏包括

_NT_TARGET_VERSION = $(_NT_TARGET_VERSION_LATEST)

+0

當微軟承諾打敗版本號檢查時,微軟並不是在開玩笑。你必須使用FileVersionInfo類,kernel32.dll總是在附近。 –

+0

@HansPassant不,你沒有。坦率地說,這是可怕的建議。微軟沒有義務更新文件版本。沒有理由首先檢測操作系統版本。 – EKW

+1

你們兩個都不正確:據說,如果清單中包含正確的密鑰,MS通常會支持舊版本檢查!第二:「沒有什麼理由可以檢測到」..嗯..你說的對,很多開發者使用它是錯誤的,阻礙了在現代Windows版本上運行應用程序。在「標準」應用程序中應該避免使用它,但有很多原因可以滿足您的需要。在設置中,以及在不同Windows版本中工作的不同情況。像.NET一樣激活Windows功能的細節行爲完全不同。 – Philm

回答

1

如果你正在使用Visual Studio生成,清單應自動編譯成EXE 。如果沒有發生,請從項目中刪除清單並重新添加。這是詳細的in this similar question

如果您使用另一個工具鏈mt.exe作爲Windows SDK的一部分構建,可用於注入清單。

或者,如果您的應用程序沒有嵌入式清單,則可以將清單作爲附加文件包含在內。只要在清單修改應用程序名稱,以匹配您的可執行文件,然後重命名該清單文件本身

<application>.exe.manifest 

,並將其放置在同一目錄下的可執行文件。但是,建議嵌入清單。

請注意,該清單在應用程序的首次運行時被緩存;更新EXE上的時間戳或重新啓動機器將導致清單在下次啓動應用程序時重新加載。

0

現在是RtlGetVersion,夥計們! :-)

https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910%28v=vs.85%29.aspx

沒有,但是這不應該是必要的正常的,真的!閱讀該版本應該根據所告知的內容使用適當的清單,並且MS不會阻止所有GetVersion/GetVersionEx調用。 您是否使用mt.exe進行檢查,如果清單是乾淨地包含的? (我還沒有嘗試Environment.OSVersion.Version,但也許這仍然是一個錯誤?)

如果某人激活了應用程序的兼容模式,即使RtlGetVersion獲取了錯誤的版本。

問題是,如果你沒有清理Win 10清單,它可能會發生兼容性問題,將遺留下來的一些程序(例如,類似於setup,install等名稱)定義爲兼容性標記。奇怪的解決方案(不是新的,自從Win 7以來就是一樣的,我看到很多人都因此而哭);-)。

要重複使Windows版本更難測試的想法:太多開發者濫用API並阻止應用程序在他們還不知道的Windows版本上工作。然後用戶指責Windows不兼容.. 這是一個非常大的錯誤,並且隨着2000年數字千年蟲問題幾乎沒有經過測試和發現多年後。 除了認證軟件,例如對於通常只允許在經過認證的硬件上允許的核崩潰,對未來版本的測試不應該阻止應用程序!

對windows版本進行測試當然對於已知的Windows不兼容性和不同的功能集有反應。

理論上,清單解決方案應該克服上述問題,因爲只有那些「知道」Windows版本(密鑰)的人才能測試正確的版本。