Windows platform sdk 標頭檔的使用

來源:互聯網
上載者:User

SDK的使用有些需要注意的地方:
例如Microsoft Platform SDK, August 2001 Edition版本的SDK,他的目標系統是Microsoft Windows 95, Microsoft Windows NT 4.0, Microsoft Windows 98, Microsoft Windows Millennium Edition (Windows Me), Microsoft Windows 2000, Microsoft Windows XP, and Microsoft Windows .NET Server 。 如果你寫的程式準備在Win 95上運行,但是使用了Win 98才有的特性,那麼該程式在Win 95上運行時就會出問題。 所以SDK必須對程式的目標平台加以評估,決定是否可以提供相應功能給使用者。 SDK通過宏來實現這個目標,給不同的系統定義不同的數字,這樣你在VC中用宏定義程式的目標運行平台,SDK根據你的定義決定開放哪些功能。 

SDK使用下面的方法決定提供哪些功能:

Guard Statement Meaning
#if _WIN32_WINNT >= 0x0400 Windows NT 4.0 and later. It is not implemented in Windows 95.
#if _WIN32_WINDOWS >= 0x0410 Windows 98. The image may not run on Windows 95.
#if _WIN32_WINDOWS >= 0x0490 Windows Me. The image may not run on Windows 95/98, Windows NT, or Windows 2000.
#if _WIN32_WINNT >= 0x0500 Windows 2000. The image may not run on Windows 95/98 or Windows NT.
#if _WIN32_WINNT >= 0x0501 Windows XP. The image may not run on Windows 95/98, Windows NT, Windows Me, or Windows 2000.
#if _WIN32_IE >= 0x0300 Internet Explorer 3.0 and later.
#if _WIN32_IE >= 0x0400 Internet Explorer 4.0 and later.
#if _WIN32_IE >= 0x0401 Internet Explorer 4.01 and later.
#if _WIN32_IE >= 0x0500 Internet Explorer 5.0 and later.
#if _WIN32_IE >= 0x0501 Internet Explorer 5.01 and later.
#if _WIN32_IE >= 0x0560 Internet Explorer 6.0 and later
#if _WIN32_IE >= 0x0600 Internet Explorer 6.0 and later

平台定義如下,需要在代碼中加上下面某個宏定義指定你的目標平台是哪個:

Minimum System Required Macros to Define
Windows 95 and
Windows NT 4.0
WINVER=0x0400
Windows 98 and
Windows NT 4.0
_WIN32_WINDOWS=0x0410 and WINVER=0x0400
Windows NT 4.0 _WIN32_WINNT=0x0400 and WINVER=0x0400
Windows 98 _WIN32_WINDOWS=0x0410
Windows 2000 _WIN32_WINNT=0x0500 and WINVER=0x0500
Windows Me _WIN32_WINDOWS=0x0490
Windows XP and
Windows .NET Server
_WIN32_WINNT=0x0501 and WINVER=0x0501
Internet Explorer 3.0, 3.01, 3.02 _WIN32_IE=0x0300
Internet Explorer 4.0 _WIN32_IE=0x0400
Internet Explorer 4.01 _WIN32_IE=0x0401
Internet Explorer 5.0, 5.0a, 5.0b _WIN32_IE=0x0500
Internet Explorer 5.01, 5.5 _WIN32_IE=0x0501
Internet Explorer 6.0 _WIN32_IE=0x0560 or
_WIN32_IE=0x0600

例如:
Win98之前的系統不提供多顯示器相關API
SDK中有相應的定義,表示只有Win 98以上的系統可以使用下面的內容:
#if(WINVER   >=   0x0500)  
  #define   SM_XVIRTUALSCREEN               76  
  #define   SM_YVIRTUALSCREEN               77  
  #define   SM_CXVIRTUALSCREEN             78  
  #define   SM_CYVIRTUALSCREEN             79  
  #define   SM_CMONITORS                         80  
  #define   SM_SAMEDISPLAYFORMAT         81   
#endif   /*   WINVER   >=   0x0500   */  

如果你的程式打算在Win95上運行,程式定義了 #define WINVER=0x0400。那麼使用SM_CMONITORS時,編譯器就會報錯,說找不到該符號。 

提示: 使用了Windows宏,如果編譯器報告找不到定義,那麼可能就是SDK對你定義的目標系統不提供支援,你需要在程式中提高你目標系統的定義,例如#define WINVER 0x0500,這樣就可以使用編譯通過了!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.