我创建了一个最简单的C++控制台应用程序,并添加了#include "windows.h",然后在main中调用LockWorkStation函数。整个程序是:#include "windows.h"
#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
LockWorkStation(); return 0;
}stdafx.h的全部内容是:
// stdafx.h : 标准系统包含文件的包含文件,
// 或是常用但不常更改的项目特定的包含文件
//#pragma once
#include <iostream>
#include <tchar.h>// TODO: 在此处引用程序要求的附加头文件
但编译的时候出现错误:
error C3861: “LockWorkStation”: 即使使用参数相关的查找,也未找到标识符可MSDN中对LockWorkStation的说明是:
Client Requires Windows "Longhorn", Windows XP, or Windows 2000 Professional.
Server Requires Windows Server "Longhorn", Windows Server 2003, or Windows 2000 Server.
Header Declared in Winuser.h; include Windows.h.
Library Link to User32.lib.
DLL Requires User32.dll.
我的确添加了windows.h,可为什么找不到表示符呢?要想调用Windows API还要怎么办呢?谢谢!
#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
LockWorkStation(); return 0;
}stdafx.h的全部内容是:
// stdafx.h : 标准系统包含文件的包含文件,
// 或是常用但不常更改的项目特定的包含文件
//#pragma once
#include <iostream>
#include <tchar.h>// TODO: 在此处引用程序要求的附加头文件
但编译的时候出现错误:
error C3861: “LockWorkStation”: 即使使用参数相关的查找,也未找到标识符可MSDN中对LockWorkStation的说明是:
Client Requires Windows "Longhorn", Windows XP, or Windows 2000 Professional.
Server Requires Windows Server "Longhorn", Windows Server 2003, or Windows 2000 Server.
Header Declared in Winuser.h; include Windows.h.
Library Link to User32.lib.
DLL Requires User32.dll.
我的确添加了windows.h,可为什么找不到表示符呢?要想调用Windows API还要怎么办呢?谢谢!
#if(_WIN32_WINNT >= 0x0500)
WINUSERAPI
BOOL
WINAPI
LockWorkStation(
VOID);
#endif /* _WIN32_WINNT >= 0x0500 */在包含Windows.h前将_WIN32_WINNT定义为0x0500或为更大的值
#define _WIN32_WINNT 0x0501
#include "windows.h"
#include "stdafx.h"
using namespace std;int _tmain(int argc, _TCHAR* argv[])
{
LockWorkStation(); return 0;
}可编译时错误一点都没有变,还是
error C3861: “LockWorkStation”: 即使使用参数相关的查找,也未找到标识符
#include "windows.h"
#include "stdafx.h"
using namespace std;
#define _WIN32_WINNT 0x0500
int _tmain(int argc, _TCHAR* argv[])
{
LockWorkStation(); return 0;
}
楼上的程序运行结果也是
error C3861: “LockWorkStation”: 即使使用参数相关的查找,也未找到标识符
不过还是不知道为什么,另开贴询问吧