void *malloc( size_t size ); Parameter size
Bytes to allocate. 分配到的字节数。
Return Value
malloc returns a void pointer to the allocated space, or NULL if there is insufficient memory available. To return a pointer to a type other than void, use a type cast on the return value. The storage space pointed to by the return value is guaranteed to be suitably aligned for storage of any type of object. If size is 0, malloc allocates a zero-length item in the heap and returns a valid pointer to that item. Always check the return from malloc, even if the amount of memory requested is small. Malloc返回一个指向分配了的空间的void指针,或者返回NULL如果没有足够的可用空间。必须使用类型强制转换来获得这个void类型的指针。返回指针指向的储存空间能够保证符合工程任何类型的储存。如果大小为0,malloc分配一个0长度的堆栈并且返回一个指向这个堆栈的有效指针。哪怕需要的内存很小,也总要检查malloc的返回值。 Remarks
The malloc function allocates a memory block of at least size bytes. The block may be larger than size bytes because of space required for alignment and maintenance information.
Malloc函数分派一块至少为size字节的内存。由于需要空间来保存队列和保持的信息,这块内存可能比size字节更大。
memset
Sets buffers to a specified character. 设定指定字符的寄存器。
void *memset( void *dest, int c, size_t count ); Parameters dest
Pointer to destination 指针地址
c
Character to set 特征设置
count
Number of characters 特征的字节数
Return Values
memset returns the value of dest. memset的返回值为dest。 Remarks
The memset function sets the first count bytes of dest to the character c. 函数memset设定dest的第一个计数字节为c。
CWnd::MessageBox
This method creates and displays a window that contains an application-supplied message and caption, plus a combination of the predefined icons and pushbuttons described in the Message-Box Styles list. Use the global function AfxMessageBox instead of this method to implement a message box in your application. int MessageBox ( LPCTSTR lpszText,
LPCTSTR lpszCaption = NULL, UINT nType = MB_OK ); Parameters
lpszText
Points to a CString object or null-terminated string containing the message to be displayed.
lpszCaption
Points to a CString object or null-terminated string to be used for the message-box caption. If lpszCaption is NULL, the default caption, Error is used.
nType
Specifies the contents and behavior of the message box. Return Value
Specifies the outcome of the function. It is zero if there is not enough memory to create the message box. Remarks
The following shows the various system icons that can be used in a message box: x ? ! i
WinMain Function
MB_ICONHAND, MB_ICONSTOP, and MB_ICONERROR MB_ICONQUESTION
MB_ICONEXCLAMATION and MB_ICONWARNING MB_ICONASTERISK and MB_ICONINFORMATION
The WinMain function is called by the system as the initial entry point for a Windows-based application. int WinMain(
HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ); Parameters
hInstance
[in] Handle to the current instance of the application. hPrevInstance
[in] Handle to the previous instance of the application. This parameter is always NULL. If you need to detect whether another instance already exists, create a uniquely named mutex using the CreateMutex function. CreateMutex will succeed even if the mutex already exists, but the function will return ERROR_ALREADY_EXISTS. This indicates that another instance of your application exists, because it created the mutex first. lpCmdLine
[in] Pointer to a null-terminated string specifying the command line for the application, excluding the program name. To retrieve the entire command line, use the GetCommandLine function. nCmdShow
[in] Specifies how the window is to be shown. This parameter can be one of the following values. SW_HIDE
Hides the window and activates another window. SW_MAXIMIZE
Maximizes the specified window. SW_MINIMIZE
Minimizes the specified window and activates the next top-level window in the Z order.
SW_RESTORE
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window. SW_SHOW
Activates the window and displays it in its current size and position. SW_SHOWMAXIMIZED
Activates the window and displays it as a maximized window. SW_SHOWMINIMIZED
Activates the window and displays it as a minimized window. SW_SHOWMINNOACTIVE
Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated. SW_SHOWNA
Displays the window in its current size and position. This value is similar to SW_SHOW, except the window is not activated. SW_SHOWNOACTIVATE
Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except the window is not actived. SW_SHOWNORMAL
Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
Return Value
If the function succeeds, terminating when it receives a WM_QUIT message, it should return the exit value contained in that message's wParam parameter. If the function terminates before entering the message loop, it should return zero.
DialogBox Function
The DialogBox macro creates a modal dialog box from a dialog box template resource. DialogBox does not return control until the specified callback function terminates the modal dialog box by calling the EndDialog function. The DialogBox macro uses the DialogBoxParam function. INT_PTR DialogBox(
HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc ); Parameters
hInstance
[in] Handle to the module whose executable file contains the dialog box template. lpTemplate
[in] Specifies the dialog box template. This parameter is either the pointer to a null-terminated character string that specifies the name of the dialog box template or an integer value that specifies the resource identifier of the dialog box template. If the parameter specifies a resource identifier, its high-order word must be zero and its low-order word must contain the identifier. You can use the MAKEINTRESOURCE macro to create this value. hWndParent
[in] Handle to the window that owns the dialog box. lpDialogFunc
[in] Pointer to the dialog box procedure. For more information about the dialog box procedure, see DialogProc.
Return Value
If the function succeeds, the return value is the nResult parameter in the call to the EndDialog function used to terminate the dialog box.
If the function fails because the hWndParent parameter is invalid, the return value is zero. The function returns zero in this case for compatibility with previous versions of Microsoft® Windows®. If the function fails for any other reason, the return value is –1. To get extended error information, call GetLastError.
#pragma pack( show | [ n] )
Specifies packing alignment for structure, union, and class members. Whereas the packing alignment of structures, unions, and classes is set for an entire translation unit by the /Zp option, the packing alignment is set at the data-declaration level by the pack pragma. The pragma takes effect at the first structure, union, or class declaration after the pragma is seen; the pragma has no effect on definitions.
When you use #pragma pack(n), where n is 1, 2, 4, 8, or 16, each structure member after the first is stored on the smaller member type or n-byte boundaries. If you use #pragma pack without an argument, structure members are packed to the value specified by /Zp. The default /Zp packing size is /Zp8.
This function returns the address of the specified exported dynamic-link library (DLL) function.
FARPROC GetProcAddress( HMODULE hModule, LPCWSTR lpProcName);
Parameters
hModule
Handle to the DLL module that contains the function. The LoadLibrary or GetModuleHandle function returns this handle.
lpProcName
Pointer to a null-terminated string containing the function name, or specifies the function’s ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the high-order word must be zero. The lpProcName parameter must be in Unicode.
Return Values
The address of the DLL’s exported function indicates success. NULL indicates failure. To get extended error information, call GetLastError.
SetWindowText
This function changes the text of the specified window’s title bar, if it has one. If the specified window is a control, the text of the control is changed. BOOL SetWindowText( HWND hWnd,
LPCTSTR lpString ); Parameters hWnd
Handle to the window or control whose text is to be changed.
lpString
Long pointer to a null-terminated string to be used as the new title or control text.
GetWindowText
This function copies the text of the specified window’s title bar—if it has one—into a buffer. If the specified window is a control, the text of the control is copied. A remote application interface (RAPI) version of this function exists, and it is called CeGetWindowText. int GetWindowText( HWND hWnd,
LPTSTR lpString, int nMaxCount ); Parameters hWnd
Handle to the window or control containing the text.
lpString
Long pointer to the buffer that will receive the text.
nMaxCount
Specifies the maximum number of characters to copy to the buffer, including the NULL character. If the text exceeds this limit, it is truncated. Return Values
The length, in characters, of the copied string, not including the terminating null character, indicates success. Zero indicates that the window has no title bar or text, if the title bar is empty, or if the window or control handle is invalid. To get extended error information, call GetLastError.
sscanf, swscanf
Read formatted data from a string. Routine Required Header sscanf
swscanf int sscanf( const char *buffer, const char *format [, argument ] ... ); int swscanf( const wchar_t *buffer, const wchar_t *format [, argument ] ... ); Parameters buffer Stored data format Format-control string argument Optional arguments Return Value Each of these functions returns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. The return value is EOF for an error or if the end of the string is reached before the first conversion. Remarks The sscanf function reads data from buffer into the location given by each argument. Every argument must be a pointer to a variable with a type that corresponds to a type specifier in format. The format argument controls the interpretation of the input fields and has the same form and function as the format argument for the scanf function; see scanf for a complete description of format. If copying takes place between strings that overlap, the behavior is undefined. InitializeCriticalSection The InitializeCriticalSection function initializes a critical section object. void InitializeCriticalSection( LPCRITICAL_SECTION lpCriticalSection ); Parameters lpCriticalSection [out] Pointer to the critical section object. Return Values This function does not return a value. In low memory situations, InitializeCriticalSection can raise a STATUS_NO_MEMORY exception. CreateEvent The CreateEvent function creates or opens a named or unnamed event object. HANDLE CreateEvent( LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCTSTR lpName ); Parameters lpEventAttributes [in] Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpEventAttributes is NULL, the handle cannot be inherited. 用来检查返回的句柄是否可以被子程序继承的SECURITY_ATTRIBUTES结构体的指针。如果lpEventAttributes,句柄将不能被继承。 bManualReset [in] If this parameter is TRUE, the function creates a manual-reset event object which requires use of the ResetEvent function set the state to nonsignaled. If this parameter is FALSE, the function creates an auto-reset event object, and system automatically resets the state to nonsignaled after a single waiting thread has been released. 如果这个成员是TRUE,函数将建立一个需要通过函数ResetEvent设定无标指状况来手动复位。如果这个成员是FALSE,函数建立一个自动复位的事件,并且在单独的等待线程被释放之后系统自动复位状况为无标志。 bInitialState [in] If this parameter is TRUE, the initial state of the event object is signaled; otherwise, it is nonsignaled. 如果这个成员是TRUE,事件的初始化状况被标志,否则不被标志。 lpName [in] Pointer to a null-terminated string specifying the name of the event object. The name is limited to MAX_PATH characters. Name comparison is case sensitive. 特定的以NULL位结束符的事件名称字符串指针。 If lpName is NULL, the event object is created without a name. 如果lpName为NULL,将建立一个没有名字的事件。 SetEvent The SetEvent function sets the specified event object to the signaled state. BOOL SetEvent( HANDLE hEvent ); Parameters hEvent [in] Handle to the event object. The CreateEvent or OpenEvent function returns this handle. Windows NT/2000/XP: The handle must have the EVENT_MODIFY_STATE access right. For more information, see Synchronization Object Security and Access Rights. Return Values If the function succeeds, the return value is nonzero. ResetEvent The ResetEvent function sets the specified event object to the nonsignaled state. BOOL ResetEvent( HANDLE hEvent ); Parameters hEvent [in] Handle to the event object. The CreateEvent or OpenEvent function returns this handle. DialogBox This function creates a modal dialog box from a dialog box template resource. DialogBox does not return control until the specified callback function terminates the modal dialog box by calling the EndDialog function. int DialogBox( HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc); Parameters hInstance [in] Handle to the module whose executable file contains the dialog box template. lpTemplate [in] Long pointer to the dialog box template. This parameter is either the pointer to a null-terminated character string that specifies the name of the dialog box template or an integer value that specifies the resource identifier of the dialog box template. If the parameter specifies a resource identifier, its high-order word must be zero and its low-order word must contain the identifier. You can use the MAKEINTRESOURCE macro to create this value. hWndParent [in] Handle to the window that owns the dialog box. lpDialogFunc [in] Long pointer to the dialog box procedure. For more information about the dialog box procedure, see DialogProc. Return Values The value of the nResult parameter in the call to the EndDialog function indicates success. –1 indicates failure. To get extended error information, call GetLastError. DialogProc This function is an application-defined callback function that processes messages sent to a modal or modeless dialog box. BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ); Parameters hwndDlg Handle to the dialog box. uMsg Specifies the message. wParam Specifies additional message-specific information. lParam Specifies additional message-specific information. Return Values Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message. If the dialog box procedure processes a message that requires a specific return value, the dialog box procedure should set the desired return value by calling SetWindowLong (hwndDlg, DWL_MSGRESULT, lResult) immediately before returning TRUE. Note that you must call SetWindowLong immediately before returning TRUE; doing so earlier may result in the DWL_MSGRESULT value being overwritten by a nested dialog box message. WaitForSingleObject The WaitForSingleObject function returns when one of the following occurs: The specified object is in the signaled state. The time-out interval elapses. To enter an alertable wait state, use the WaitForSingleObjectEx function. To wait for multiple objects, use the WaitForMultipleObjects. DWORD WaitForSingleObject( HANDLE hHandle, DWORD dwMilliseconds ); Parameters hHandle [in] Handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section. If this handle is closed while the wait is still pending, the function's behavior is undefined. dwMilliseconds [in] Time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses. Return Values If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values. Value Meaning The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled. The state of the specified object is signaled. The time-out interval elapsed, and the object's state is nonsignaled. WAIT_ABANDONED WAIT_OBJECT_0 WAIT_TIMEOUT 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务