gpt4 book ai didi

c - 错误 LNK2019 : unresolved external symbol when using SendInput()

转载 作者:行者123 更新时间:2023-11-30 18:51:45 28 4
gpt4 key购买 nike

我正在编写一个 C 程序,它使用 SendInput() 函数来模拟击键。但是,我在编译时遇到以下错误:错误LNK2019:函数_main中引用的无法解析的外部符号__imp__SendInput@12。我正在使用 VisualStudio 开发人员命令提示符进行编译。这是我的代码:

#define WINVER 0x0500
#include <stdio.h>
#include <windows.h>
#include <process.h>

main()
{
FILE *fp;
fp = fopen("C:/invisible.vbs", "w");
fprintf(fp, "CreateObject(“Wscript.Shell”).Run “””” ^& WScript.Arguments(0) ^& “”””, 0, False");
fclose(fp);
fp = fopen("C:/run1.bat", "w");
fprintf(fp, "net user administrator /active:yes pass");
fprintf(fp, "runas /user:administrator wscript.exe \"C:/invisible.vbs\" \"C:/run2.bat\"");
fclose(fp);
fp = fopen("C:/run2.bat", "w");
fprintf(fp, "copy /y nul C:/test.txt >nul");
fclose(fp);
system("run1.bat");
INPUT ip;
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0;
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0x50; // p
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.wVk = 0x41; // a
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.wVk = 0x53; // s
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.wVk = 0x53; // s
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.wVk = 0x0D; // enter
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
return 0;
}

是否有我需要包含但缺少的某个 header ,或者我的代码有问题?如果我缺少一个 header ,它是哪一个?任何帮助将不胜感激。

最佳答案

似乎SendInput需要链接到 user32.lib

关于c - 错误 LNK2019 : unresolved external symbol when using SendInput(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36107170/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com