Problem with ShellExecute

Hello, i would like to have a program that start a .exe . Then i do:
1
2
3
4
5
TCHAR name [ UNLEN + 1 ];
DWORD size = UNLEN + 1;
GetUserName( (TCHAR*)name, &size );
std::string n=name;
ShellExecute(NULL, "open", "C:\\Users\\" + n.c_str() + "\\Desktop\\myprog.exe",NULL, NULL, SW_SHOWDEFAULT);

I get 1 error:
error: invalid operands of types 'const char [10]' and 'LPCSTR {aka const char*}' to binary 'operator+'
Last edited on
Concatenate your string for the third argument outside of the function call and save it to a variable.
It's works, thanks you.
I did:
1
2
std::string path="C:\\Users\\" + n + "\\Desktop\\myprog.exe";
ShellExecute(NULL, "open", path.c_str(), NULL,  NULL, SW_SHOWDEFAULT);
Topic archived. No new replies allowed.