I want my program to open a file when you run it, and I've done a lot of searching and found a lot of snippets, but nothing is working. Here's what I have:
The compiler isn't returning any errors. This isn't the whole program, just the little snippit that's giving me problems.
What do I need to do for this file to open?
The error is 'identifier '_T' is unidentified'. Which is fixed if I put 'HINSTANCE' before 'ShellExecute(' but then I get an error for the comma right after '_T("open"),' it says "Expecting a ')'.
Try using TEXT() instead. For some strange reason that has worked for me in the past. I would check your #includes to make sure you have the Windows header that defines the _T() macro.
You'll need to escape ("\\") or replace (with forward slashes) those backslashes in your path too, and I'm not sure if ShellExecute will expand environment variables?
-edit-
ShellExecuteEx does though!
1 2 3 4 5 6 7 8
SHELLEXECUTEINFO sei = { sizeof sei };
sei.fMask = SEE_MASK_DOENVSUBST;
sei.lpVerb = TEXT("open");
sei.lpFile = TEXT("%userprofile%\\Pictures\\wedding.jpg");
sei.nShow = SW_SHOWNORMAL;
ShellExecuteEx(&sei);
-edit-
Just noticed also, _T(" %userprofile%\nPictures\n ") you have a space before and after the path name, and new line characters before and after "Pictures"..?
ShellExecuteEx() worked perfectly.
The space before and after the file-path was accidental, I was searching around the forums and found a similar ShellExecute() problem, and in the code they used it had those spaces. I copied and pasted and forgot about it. Whoops!
Thanks for all the help!