最基础的Win32程序中,WNDCLASS中的成员变量hInstance应该设何值?
#include <afxwin.h>
#include <stdio.h>
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here
WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(NULL,IDC_CROSS);
wc.hIcon = LoadIcon(NULL,IDI_ERROR);
wc.hInstance = hInstance;
上面红色程序如果设为NULL,依然可以运行程序,请问两者有什么区别?
看MSDN说是:拥有这个窗口类的窗口过程实例句柄