I m trying to open a file using shellexecute command my code is
ShellExecute(NULL,NULL,itemPath,NULL,NULL,SW_SHOW);
or
ShellExecute(NULL,L"open",itemPath,NULL,NULL,SW_SHOW);
I have used both ways but when I m giving path of a folder it opens a folder but when I m giving a full specified path of a file it doesn't work. one thing more if I m giving a hardcode path like for example
ShellExecute(NULL,L"open",L"E:\\abc.xlsx",NULL,NULL,SW_SHOW);
than it opens this file. can any one explain why it is happening.
E:\\abc.xlsx
. – Jonathan PotterShellExecute
appears to work when passing a string literal with the exact same content as aCString
variable, then more likely than not your variable doesn't hold the value you think it does. At any rate, this isn't nearly enough information to help answer the question. You need to provide a minimal reproducible example. You should also consider calling ShellExecuteEx instead for better error reporting. – IInspectable