Originally Posted by
Salem
Which OS/Compiler are you using?
I use DevCpp.
Originally Posted by
ZuK
I know windows doesn't support filenames containing spaces very well.
One way could be to find out that funny 8.3-style path and use that.
Kurt
That wouldn't be a good solution. The program I'm planning to make will read the program path from an ini file and launch it. Then I would need a function to convert the path to the 8.3 format. There must be an easier solution.
EDIT: After I looked in your FAQ I found a solution to the problem. It isn't exactly what I want but it works:
Code:
#include <windows.h>
int main(void)
{
char szPath[] = "C:\\Program\\Windows Media Player\\wmplayer.exe";
PROCESS_INFORMATION pif; //Gives info on the thread and..
//..process for the new process
STARTUPINFO si; //Defines how to start the program
ZeroMemory(&si,sizeof(si)); //Zero the STARTUPINFO struct
si.cb = sizeof(si); //Must set size of structure
BOOL bRet = CreateProcess(
szPath, //Path to executable file
NULL, //Command string - not needed here
NULL, //Process handle not inherited
NULL, //Thread handle not inherited
FALSE, //No inheritance of handles
0, //No special flags
NULL, //Same environment block as this prog
NULL, //Current directory - no separate path
&si, //Pointer to STARTUPINFO
&pif); //Pointer to PROCESS_INFORMATION
if(bRet == FALSE)
{
MessageBox(HWND_DESKTOP,"Unable to start program","",MB_OK);
return 1;
}
CloseHandle(pif.hProcess); //Close handle to process
CloseHandle(pif.hThread); //Close handle to thread
return 0;
}
The only problem is that it's limited to windows. Are there any other, more portable functions that does the same thing?