错误 LNK2019:使用 SendInput() 时无法解析的外部符号

error LNK2019: unresolved external symbol when using SendInput()

我正在编写一个使用 SendInput() 函数模拟击键的 C 程序。但是,编译时出现以下错误:error LNK2019: unresolved external symbol __imp__SendInput@12 referenced in function _main。我正在使用 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 需要 link 到 user32.lib