环境
Win10,VC6.0
问题
当我使用Windows默认线程池提交工作程序时,
它编译错误。我使用VC6.0,并且包含了Windows.h
但找不到功能。请帮助我。
main.cpp
#include "main.h"
int KeyMap[128];
int main()
{
ScriptHeadTail* pSht = (ScriptHeadTail*)KeyMap[101];
if (pSht != NULL){
TrySubmitThreadpoolCallback(ProcessHook, (LPVOID)(pSht->head), NULL);
}
Sleep(1000);
return 1;
}
VOID CALLBACK ProcessHook(PTP_CALLBACK_INSTANCE instance, PVOID lParam)
{
ExecuteScript* pScript = (ExecuteScript*)lpParam;
while (pScript != NULL){
switch (pScript->type)
{
case KEYBOARD :
{
printf("send key : %d\n", pScript->value);
break;
}
case LBUTTON :
{
printf("left button down : %d\n", pScript->value);
break;
}
case RBUTTON :
{
break;
}
case IDLE :
{
Sleep(pScript->value);
break;
}
}
pScript = pScript->next;
}
return 1;
}
main.h
#include <Windows.h>
#include <stdio.h>
struct ExecuteScript
{
int type;
int value;
ExecuteScript* next;
};
struct ScriptHeadTail
{
ExecuteScript* head;
ExecuteScript* tail;
};
BOOL Init(LPCSTR configFile);
BOOL LoadConfigFile(const char* configFile);
VOID CALLBACK ProcessHook(PTP_CALLBACK_INSTANCE instance, PVOID lParam);
const int ASCII_LEN = 128;
const int KEYBOARD = 1;
const int LBUTTON = 2;
const int RBUTTON = 3;
const int IDLE = 4;
结果
--------------------Configuration: ReadFileTest - Win32 Debug---------- ----------
Compiling...
main.cpp
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2065: 'PTP_CALLBACK_INSTANCE' : undeclared identifier
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2146: syntax error : missing ')' before identifier 'instance'
c:\users\jasey\windows-program\readfiletest\main.h(20) : warning C4229: anachronism used : modifiers on data are ignored
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2182: 'ProcessHook' : illegal use of type 'void'
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2059: syntax error : ')'
c:\users\jasey\windows-program\readfiletest\main.cpp(13) : error C2065: 'TrySubmitThreadpoolCallback' : undeclared identifier
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2146: syntax error : missing ')' before identifier 'instance'
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : warning C4229: anachronism used : modifiers on data are ignored
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2182: 'ProcessHook' : illegal use of type 'void'
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2086: 'ProcessHook' : redefinition
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2059: syntax error : ')'
c:\users\jasey\windows-program\readfiletest\main.cpp(61) : error C2143: syntax error : missing ';' before '{'
c:\users\jasey\windows-program\readfiletest\main.cpp(61) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.
Creating browse info file...
ReadFileTest.exe - 1 error(s), 0 warning(s)
答案 0 :(得分:1)
该API是Windows Vista中引入的。 VC 6支持的最新Windows SDK适用于Windows Server 2003,它早于Vista。
修复的最佳方法是将Visual C ++升级到一些较新的版本。