Like the TT says, I make a system call to run another program, but it also loads cmd.exe for some reason, is there anyway to make it not do that? it's really annoying.
the program I'm calling is made using the windows api as a WS_POPUP style if that matters.
I'm looking at CreateProcess atm, but it won't accept a string as the second argument and it wants a wchar* instead, how do I turn simple text into that data type?
that's my code and I get the following error: error: cannot convert 'char*' to 'WCHAR*'for argument '2' to 'BOOL CreateProcessW(const WCHAR*, WCHAR*, _SECURITY_ATTRIBUTES*, _SECURITY_ATTRIBUTES*, BOOL, DWORD, void*, const WCHAR*, _STARTUPINFOW*, _PROCESS_INFORMATION*)'
I'm coding and compiling in QT Creator if that makes a difference
I had it wrong. I normally just dereference the first character in the string, in your case it would look like this CreateProcess(0, &str[0], 0, 0, FALSE, 0, 0, 0, &si, &pi)
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
char * cstr, *p;
wstring str = (L"monocle.exe");//wstring type and the L to convert the string to wstring.
if(CreateProcess(0, &str[0], 0, 0, FALSE, 0, 0, 0, &si, &pi))
{
// optionally wait for process to finish
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
Yes, this is the good old "I mix WinAPI names with string data types without caring about their actual signatures".
1. If you use wide strings, you MUST call the WinAPI functions using their -W names. In your case, CreateProcessW().
2. If you use narrow (normal) strings, you MUST call the WinAPI functions using there -A names. In your case, CreateProcessA().
3. If you use the WinAPI names without any suffix (CreateProcess() in your case), you MUST use a data type that changes depending on the UNICODE #define: