关于VC++2005在使用windows API出现的问题
为什么我这样编#include "stdafx.h"
#include <windows.h>
#pragma comment(lib,"User32.lib")
#define WinMain _stdcall
int WinMain(int argc, _TCHAR* argv[])
{
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
MessageBox(NULL,
TEXT("开始学习Windows编程"),
TEXT("消息对话框"),
MB_OK);
return 0;
}
会有
1>d:\my documents\visual studio 2005\projects\wei\wei\wei.cpp(8) : error C2059: syntax error : '('
1>d:\my documents\visual studio 2005\projects\wei\wei\wei.cpp(9) : error C2143: syntax error : missing ';' before '{'
1>d:\my documents\visual studio 2005\projects\wei\wei\wei.cpp(9) : error C2447: '{' : missing function header (old-style formal list?)的错误啦
错误出现在{
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
我已经装了sdk并在sdk安装中选择custom,并在configuration options选择“register environment variable”选项中选择entire feature will be installed on local hard drive,在vc中的tools选项中选择options中的VC++directories在executable files,include files,library files 分别添加了路径,可是也出现以上问题,有哪个高手帮帮忙呀
[解决办法]
那你改成
#include "stdafx.h"#include <windows.h>#pragma comment(lib,"User32.lib")int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ MessageBox(NULL, TEXT("开始学习Windows编程"), TEXT("消息对话框"), MB_OK); return 0;}