-------------------Configuration: 03 - Win32 Debug--------------------
Linking...
LINK : fatal error LNK1168: cannot open Debug/03.exe for writing
Error executing link.exe.03.exe - 1 error(s), 0 warning(s)以是是程序的源代码(winAPI);
#include <windows.h>
#include <stdio.h>LRESULT CALLBACK lilight(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);
int WINAPI WinMain(
  HINSTANCE hInstance,  // handle to current instance
  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,      // pointer to command line
  int nCmdShow          // show state of window
){
WNDCLASS win;
win.cbClsExtra=0;
win.cbWndExtra=0;
win.hbrBackground=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
win.hCursor=LoadCursor(NULL,IDC_APPSTARTING);
win.hIcon=LoadIcon(NULL,IDI_EXCLAMATION);
win.hInstance=hInstance;
win.lpfnWndProc=lilight;
win.lpszClassName="bright";
win.lpszMenuName=NULL;
win.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&win);
        HWND hwnd;
hwnd=CreateWindow("Weixin2003","输入法",WS_OVERLAPPEDWINDOW,
0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
    UpdateWindow(hwnd); MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
        TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;}
  LRESULT CALLBACK lilight(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
){
switch(uMsg)
{
case WM_CHAR:
        char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"weixin",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"www.baidu.com","www.sian.com.cn",0);
        HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"计算机",strlen("计算机"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"学校",strlen("学校"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"你真的要退出吗?","lilight",MB_YESNO))
{
            DestroyWindow(hwnd);
}
break;
        case WM_DESTROY:
PostQuitMessage(0);
break;
    default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}

解决方案 »

  1.   

    你的exe执行之后没有退出,去任务管理器把它卡查掉就OK了~
      

  2.   

    楼上的是高手啊!我试了一下果然是这个样子的!把进程关了,重新运行就OK了!但问题又来了,编译的时候出现了问题:
    -------------------Configuration: 03 - Win32 Debug--------------------
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/03.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.03.exe - 2 error(s), 0 warning(s)
      

  3.   

    估计是你的项目建错了,应该是win32 application 而建了win32 console application
      

  4.   

    楼上是对的
    不过还有一个问题: 
    hwnd=CreateWindow("bright"           //这里的应该是bright
       ,TEXT("输入法"),WS_OVERLAPPEDWINDOW,  
       0,0,600,400,NULL,NULL,hInstance,NULL);
    类名应该和win的win.lpszClassName="bright"一样
      

  5.   

    如果是win32 application项目,请查project->link
    它的object/library 是以下内容
    kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 
    没有LIBCD.lib
    另外project options 中的/subsystem应为windows
      

  6.   

    setting中Option的subsystem:console改成windows试试
      

  7.   

    把/subsystem:console
    改为/subsystem:windows