I am tying to open a program by using the system command. system ("C:\\Users\\someone\\Desktop\\somthing.exe");
And that works fine, but if I do something like this it will not work because of the space between Program and Files. system ("C:\\Program Files\\something.exe");
You could use ShellExecute, part of the Windows' Library. I assume you are fond of the WinAPI due to you posting this in Windows Forum, but you may not know what I am talking about.
Anyway, ShellExecute can open a file. So, example:
1 2
// To open a program:
ShellExecute(NULL, "open", "C://Program Files (x86)//something.exe", NULL, NULL, SW_SHOWNORMAL);
What that will do is open the program (or according to the function, open the file). Example 2:
1 2 3
// This will open Notepad, using a char.
char notepad[] = "notepad.exe";
ShellExecute(NULL, "open", notepad, NULL, NULL, SW_SHOWNORMAL);
I assume you know to include <windows.h> at the top of your file, but just in case you don't, put this at the top: #include <windows.h>
That would be because ShellExecuteW is for wide strings, aka, wchar_t, as said in your error. You can use ShellExecuteW, and to do so, you would just change the parameters to L"", instead of just regular "". So, example time:
You could also use ShellExecuteA, which is just ShellExecute, except using chars. Example time 2:
ShellExecuteA(NULL, "open", "File Path To .exe File", NULL, NULL, SW_SHOWNORMAL);
I always use A functions in windows, due to my passionate hate for wide strings.
And really (irrelevant) I don't use the WinAPI much anymore. I use cross platform stuff. But, the choice is always yours, however.
Your welcome, glad to help! Just remember that WinAPI has functions for all string types (in most cases, at least). So, for CreateProcess, there is CreateProcessA, CreateProcessW... For CreateWindow: CreateWindowA, CreateWindowW, and so on