Hello, my name is legolizard. I am not *totally* new to C++, but I need just a small bit of help. I need to use the CreateProcess() in my program, however it gives me a segmentation fault every time I run it, when I have done a very similar thing before with no errors. v.v
#include <Windows.h>
int main(){
STARTUPINFO suf;
PROCESS_INFORMATION pi;
memset(&suf, 0, sizeof(suf));
memset(&pi, 0, sizeof(pi));
suf.cb = sizeof(suf);
CreateProcess(NULL,
L"\"C:\\Program Files (x86)\\ImageJ\\ImageJ.exe\"" ,// Could the error be here?
NULL,
NULL,
TRUE,
CREATE_NO_WINDOW,
NULL,
NULL,
&suf,
&pi);
return 0;
}
Any adive would be greatly appreciated. Thank you. : )
More info: I am using MSVC++ compiler, but oddly it works(without the L) on MingW. O.o
:D I actually figured it out. There is a flag I found CREATE_UNICODE_ENVIROMENT that makes everything work. ^_^
Beware that CreateprocessW() does not take a const string as second argument, it could change it in some conditions, which will crash your application too.