读书人

非 “超级”之 高手不能解决的有关问题

发布时间: 2012-05-22 18:18:54 作者: rapoo

非 “超级”之 高手不能解决的问题!!!
一个编译错误问题! 超级编译错误难题!! 楼主跪求答案!!!
====================================================
问题如下:
编译错误!
C:\Documents and Settings\Administrator\桌面\InputMessage\InputMessage.cpp(34) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\Documents and Settings\Administrator\桌面\InputMessage\InputMessage.cpp(34) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

源代码================================================
#include "stdafx.h"
#include <windows.h>
dllimport("USER32.DLL")
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
INPUT kbinput;
ZeroMemory( &kbinput, sizeof(INPUT) );

kbinput.type = INPUT_KEYBOARD;
kbinput.ki.wVk = VK_LWIN;

SendInput( 3, kbinput, sizeof(INPUT) );
return 0;
}




[解决办法]
INPUT 是啥东西?
[解决办法]
这是非“超级”之高手不能遇到的问题,我在另一帖子里回复了。
[解决办法]
dllimport("USER32.DLL") 这个语句注释掉
[解决办法]
test...
[解决办法]
#pragma comment(lib,"user32")
[解决办法]
先帮你顶啊!
[解决办法]
你需要的是合适的头文件
[解决办法]
在stdafx.h中的#include <windows.h>前面加一句#define _WIN32_WINNT0x0500

因为只有WIN98以后版本的操作系统才支持这个函数


C/C++ code
#include "stdafx.h"int APIENTRY WinMain(HINSTANCE hInstance,                      HINSTANCE hPrevInstance,                      LPSTR     lpCmdLine,                      int       nCmdShow) {     INPUT kbinput;     ZeroMemory( &kbinput, sizeof(INPUT) );         kbinput.type = INPUT_KEYBOARD;     kbinput.ki.wVk = VK_LWIN;         SendInput(3, &kbinput, sizeof(INPUT) );     return 0; }
[解决办法]
// stdafx.h
#pragma once
#define _WIN32_WINNT 0x0500
#include <windows.h>
// ……

// InputMessage.cpp
#include "stdafx.h"
#pragma comment(lib, "user32.lib")
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
INPUT kbinput;
ZeroMemory( &kbinput, sizeof(INPUT) );
kbinput.type = INPUT_KEYBOARD;
kbinput.ki.wVk = VK_LWIN;
SendInput( 3, &kbinput, sizeof(INPUT) );
return 0;
}

读书人网 >VC/MFC

热点推荐