簡體   English   中英

為XP和Vista / Windows 7創建Win32應用程序

[英]Creating a Win32 application for both XP and Vista/Windows 7

我已經使用純Win32 API(沒有MFC或WPF)在C ++中編寫了一個應用程序。 我希望在Windows XP和Windows Vista / Windows 7下都可以運行相同的.exe。

我正在使用清單將視覺樣式添加到應用程序中的控件。 但是,當我在XP機器上測試該應用程序時,按鈕沒有顯示。 只有編輯控件和菜單欄可以。

編輯:我想我忘了提及這一點,但該應用程序在Windows 7 / Vista上運行良好。 編輯2:我使用的是MinGW編譯器,我認為這是清單問題,因此我將其刪除並重新編譯了程序。 但是按鈕仍然不顯示。 我正在使用的清單如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="1.0.0.0"
    processorArchitecture="*"
    name="BlackJack.Viraj"
    type="win32"
/>
<description>Your application description here.</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.2600.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
</assembly>

問題出在清單上還是其他原因?

確保調用InitCommonControlsEx

這是另一回事。 假設它們是普通的標准按鈕,則無論清單是什么樣還是不存在,都應該顯示它們。 發生了其他事情。

除非您使用新的Windows 7 API,否則標准應用程序將在兩個平台上均能正常運行。 此外,Windows 7還具有兼容模式,如果您發現損壞的內容,可以嘗試一下。

您確定在程序開始時已調用InitCommonControls API嗎?

看看為什么它很重要-http://blogs.msdn.com/b/oldnewthing/archive/2005/07/18/439939.aspx

我建議您引用一個純Win32應用程序http://blogs.msdn.com/b/oldnewthing/archive/2005/04/22/410773.aspx

另外,我建議將清單文件放在源文件的鏈接器選項中。

#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

清單很好。 因此,問題必須出在您的代碼中。 創建主題應用程序與非主題應用程序並不完全相同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM