回 帖 发 新 帖 刷新版面

主题:利用api函数编写的windows程序

#include<windows.h>

#define NULL 0
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,    HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
    HWND hwnd;
    MSG Msg;
    WNDCLASS wndclass;
    char lpszClassName[]="窗口";
    char lpszTitle[]="My_Windows";
    wndclass.style=0;
    wndclass.lpfnWndProc=WndProc;
    wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;
    wndclass.hInstance=hInstance;
    wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
    wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName=NULL;
    wndclass.lpszClassName=lpszClassName;
    if(!RegisterClass(&wndclass))
    {
        MessageBeep(0);
        return FALSE;
    }
    hwnd=CreateWindow(
                      lpszClassName,
                      lpszTitle,
                      WS_OVERLAPPEDWINDOW,
                      CW_USEDEFAULT,
                      CW_USEDEFAULT,
                      CW_USEDEFAULT,
                      CW_USEDEFAULT,
                      NULL,
                      NULL,
                      hInstance,
                      NULL,
                      );
    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);
    while(GetMessage(&Msg,NULL,0,0))
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
    switch(message)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
    default:
        return DefWindowProc(hwnd,message,wParam,lParam);
    }
    return (0);
}
上面是一个windows应用程序,我在win32 console application上编译没错误,运行有错误,
提示是unresolved externals
帮我看一下!
windows应用程序可以在上面说的那个东东上运行吧?

回复列表 (共1个回复)

沙发

不能用控制台,要用win32 appliaction

我来回复

您尚未登录,请登录后再回复。点此登录或注册