#include "ShellAPI.h";
ShellExecute(Handle,NULL,"file.txt",NULL,NULL,SW_RESTORE);
Run Code Online (Sandbox Code Playgroud)
为什么此代码不起作用?
错误画面如下:

几个问题:
windows.h然后才能包含shellapi.h。<>在标头周围使用而不是""。;的#include指令后不应使用分号。ShellExecute()调用可能需要在一个函数中int main(void)。Handle没有定义。您可能需要NULL每个ShellExecute()文档(您应该已经阅读过)。#include <windows.h>
#include <ShellAPI.h>
int main(void) {
ShellExecute(NULL, NULL, "file.txt", NULL, NULL, SW_RESTORE);
return 0;
}
Run Code Online (Sandbox Code Playgroud)