Win32 function prototype
Win32 function prototype is divided into ordinary, ANSI and Unicode three. In fact, if, strictly speaking, not common this method, which is only two ANSI and Unicode. General, are generally MSDN Developer documents presented in the form of direct. For example, here is the ordinary SetWindowText prototype:
BOOL SetWindowText (HWND hwnd, LPCTSTR lpText);
In fact, the statement contains SetWindowText function is the first document with specific Acer achieved:
# Ifdef UNICODE
# Define SetWindowText SetWindowTextW
# Else
# Define SetWindowText SetWindowTextA
# Endif / /! UNICODE
Pretreatment procedures will be in accordance with the definition of a replacement-UNICODE will replace the function is not ANSI version is Unicode version. Function at the end of the "A" representative "ANSI" and "W" to represent "Wide." First document also contains two different versions of the function prototype statement:
ANSI prototype:
BOOL WINAPI SetWindowTextA (HWND hWnd, LPCSTR lpString);
Unicode prototype:
BOOL WINAPI SetWindowTextW (HWND hWnd, LPCWSTR lpString);
Below is the first document in winuser.h SetWindowText function statements and macro definitions:
WINUSERAPI
BOOL
WINAPI
SetWindowTextA (
HWND hWnd,
LPCSTR lpString);
WINUSERAPI
BOOL
WINAPI
SetWindowTextW (
HWND hWnd,
LPCWSTR lpString);
# Ifdef UNICODE
# Define SetWindowText SetWindowTextW
# Else
# Define SetWindowText SetWindowTextA
# Endif / /! UNICODE
Note that the use of string parameter, the general use of the prototype is LPCTSTR, ANSI prototype using the LPCSTR, and the use of Unicode is LPCWSTR prototype.
We usually use their own procedures in general prototype function, in the time of need only definition UNICODE, this function will use the Unicode version. If no definition of UNICODE, the default function of the use of ANSI version. Of course, we can also call functions, directly reflect the use of ANSI or Unicode version version of the specific methods in general is a function of the prototype add "A" or "W", but I do not advocate doing so because prone to confusion .
This method is usually used in the use of string parameter function, under normal circumstances are in the normal manner. What is the normal way? Are normal people with normal way, you are normal? Ha ha. As used in the VB is Unicode, so when used in VB must pay attention to, I think people who are familiar with VB this point very clearly. "W" at the end of the string function parameters using wide-character, that is, under normal circumstances, we see an English version of a Chinese character or use two bytes to store, but some functions are the only versions of Unicode.
MSDN document on the development of the narrative of the function have a QuickInfo, QuickInfo will explain the function of whether the version containing ANSI and Unicode version.
* Reprint please notify the author and indicate the source of CSDN Welcomes You! *
* Author: Leipeipei (goodname008) *
* E-mail: goodname008@163.com *
* Column: http://blog.csdn.net/goodname008 *
*——————————————-*
Tags: function, prototype, win32








0 Comments to “Win32 function prototype”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.