注册 登录
编程论坛 Windows论坛

程序中0与NULL还有区别?

David_o 发布于 2012-02-23 23:36, 51 次点击
#include "windows.h"

LRESULT WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM IParam)
{
     return DefWindowProc(hWnd,uMsg,wParam,IParam);
}

int WinMain(HINSTANCE hlnstance,HINSTANCE hPrevlnstance,LPSTR lpCmdLine,int nCmdShow)
{
    HWND hWnd=0;
    WNDCLASS window_o={0};
    MSG nMsg={0};
    window_o.style = CS_HREDRAW|CS_VREDRAW;
    window_o.lpfnWndProc = (WNDPROC)WndProc;
    window_o.cbWndExtra =0;
    window_o.hInstance = 0;
    window_o.hIcon=NULL;
    window_o.hCursor=NULL;
    window_o.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
    window_o.lpszMenuName = NULL;
    window_o.lpszClassName = "DDD";
    RegisterClass(&window_o);
    hWnd = CreateWindow("DDD","David",WS_OVERLAPPEDWINDOW,100,100,300,500,NULL,NULL,hlnstance,NULL);
    ShowWindow(hWnd,SW_SHOW);
    UpdateWindow(hWnd);
    while(GetMessage(&nMsg,NULL,0,0))
    {
          TranslateMessage(&nMsg);
          DispatchMessage(&nMsg);
    }
}
1 回复
#2
lonmaor2012-02-24 11:05
NULL可以被定义为0,在不同的系统中,也可能被定义为其它。
1