Windows API parameter specifier prefix detailed

Source: Internet
Author: User
Tags integer

Using MASM to write Windows programs is actually dealing with Windows APIs, and it is impossible for one person to remember all API usage, so API reference manuals are essential, and the API reference manual is represented by the Hungarian notation, The following table is a detailed explanation of those prefixes in the API prototype, which hopefully helps beginners.

Source: MicroSoft MSDN Platform SDK reference
a array  array
b bool (int)   Boolean (integer)
by unsigned Char (Byte)   unsigned character (bytes)
c char  character (bytes)
Cb count of bytes  bytes
Cr color Reference value  color (reference) value
Cx count of x (short)  x (shorter integer)
dw dword  (unsigned long)   Double word (unsigned long integer)
f flags  (usually multiple bit values)   flag (typically with multiple digits)
fn function  function
g_ global  global
h handle  handle
i integer  integer
l long  Long integer
LP  long pointer  Long Pointer
M_ data member of a class  data members of a class
N short int  short integer
p  pointer  pointer
s string  string
Sz zero terminated string  a 0-terminated string
Tm text metric   Text rule
u unsigned int  unsigned integer
ul unsigned long (ULONG)   unsigned long integer
W word (Unsigned Shorter)   unsigned short integer
x,y x, y coordinates (short)   coordinate value/small integer
v void  null

For example, the API function Createwindowsex,api prototype is as follows:
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
);
So according to the prefix table, dwExStyle needs a double word value, lpclassname and lpwindowname need a long pointer to the string (the offset address in the MASM), and X, y indicates that the integer value needs to be passed. Nwidth and nheight represent the passing of short integers, hwndparent means that a window handle is required, Hmenu represents passing a menu handle, HINSTANCE indicates that the program instance handle is passed, and Lpparam indicates that the long pointer (address) can be passed.
Note that when you look at the prefix, please do not look at the previous type specifier, but to see the word prefix, such as a DWORD dwExStyle, only to see dwExStyle to know that the two words passed.
There are other combinations, just a little attention can be done, for example, LPFN represents the long pointer to the function, in the MASM is the address of a function, as well as lpsecurityattributes, and so on, is a pointer to the SECURITY_ATTRIBUTES structure of the long (address), lpvbuffer means to pass a cache (buffer) long pointer (LP) or null (void), and some without a prefix is the word is enough to explain its meaning. Wait, knowing the meaning of these prefixes will allow you to quickly master the API when learning it. And can rule out some mistakes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.