windows api參數說明符首碼詳解

來源:互聯網
上載者:User

使用MASM寫Windows程式,其實就是和Windows API打交道,而一個人是不可能記住所有的API用法的,所以API參考手冊是必不可少的,API的參考手冊中函數原型是按匈牙利標記法表示的,下面這個表就是API原型中那些首碼的詳細解釋,希望對初學者有協助。

資料來源:MicroSoft MSDN Platform SDK 參考
a Array 數組
b BOOL (int) 布爾(整數)
by Unsigned Char (Byte) 無符號字元(位元組)
c Char 字元(位元組)
cb Count of bytes 位元組數
cr Color reference value 顏色(參考)值
cx Count of x (Short) x的集合(短整數)
dw DWORD (unsigned long) 雙字(無符號長整數)
f Flags (usually multiple bit values) 標誌(一般是有多位的數值)
fn Function 函數
g_ global 全域的
h Handle 控制代碼
i Integer 整數
l Long 長整數
lp Long pointer 長指標
m_ Data member of a class 一個類的資料成員
n Short int 短整數
p Pointer 指標
s String 字串
sz Zero terminated String 以0結尾的字串
tm Text metric 文本規則
u Unsigned int 不帶正負號的整數
ul Unsigned long (ULONG) 無符號長整數
w WORD (unsigned short) 無符號短整數
x,y x, y coordinates (short) 座標值/短整數
v void 空

比如說API函數CreateWindowsEx,API原型如下:
HWND CreateWindowEx(
DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu, or child-window identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);
那麼根據上述首碼表可以得出,dwExStyle需要一個雙字值,lpClassName與lpWindowName需要一個指向字串的長指標(在MASM中則是位移地址),x、y表示需傳遞整數值,nWidth與nHeight表示傳遞短整數,hWndParent表示需要一個視窗控制代碼,hMenu表示傳遞一個菜單控制代碼,hInstance表示傳遞的是程式執行個體控制代碼,lpParam表示可以傳遞長指標(地址)。
注意看首碼時請不要看前面的類型說明符,而是要看詞的首碼,如DWORD dwExStyle,只需要看dwExStyle就知道傳遞的是雙字數。
另外還有其它的組合,只要稍注意就能行,比如說lpfn表示指向函數的長指標,在MASM中則是一個函數的地址,,還有像lpSecurityAttributes之類的,則是指向SECURITY_ATTRIBUTES結構的長指標(地址),lpvBuffer表示傳遞一個緩衝(Buffer)長指標(lp)或者為空白(void),還有一些沒有首碼的則是這個詞已經足夠說明它的意思了。等等,熟悉這些首碼的含義可以讓你在學習API的時候進行快速的掌握。並能排除一些錯誤。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.