#include "ShellAPI.h";
ShellExecute(Handle,NULL,"file.txt",NULL,NULL,SW_RESTORE);
Why does this code not work?
Here the error screen:
Several problems:
windows.h
before you can include shellapi.h
.<>
around the header instead of ""
.;
after your #include
directive.ShellExecute()
call needs to be in a function, probably int main(void)
.Handle
is not defined. You probably want NULL
per the ShellExecute()
documentation (which you should have already read).#include <windows.h>
#include <ShellAPI.h>
int main(void) {
ShellExecute(NULL, NULL, "file.txt", NULL, NULL, SW_RESTORE);
return 0;
}