I'm using Windows 8 x64 Enterprise, VS2010.
I've some problem on CreateProcess()
.
I've created a Win32 Console project to execute _backround_manipulator.exe
, my application.
Implementation here.
#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
DWORD RunManipulator(TCHAR* tszProcessPath);
int _tmain(int argc, _TCHAR* argv[])
{
_tprintf(_T("---Manipulator will start...---\n"));
if(0x08 == RunManipulator(_T("_background_manipulator.exe")))
_tprintf(_T("---Manipulator Started.---\n"));
else
_tprintf(_T("---Manipulator cannot run.---\n"));
return 0;
}
DWORD RunManipulator(TCHAR* tszProcessPath)
{
STARTUPINFO _v_startupinfo;
PROCESS_INFORMATION _v_processinfo;
ZeroMemory(&_v_startupinfo, sizeof(STARTUPINFO));
ZeroMemory(&_v_processinfo, sizeof(PROCESS_INFORMATION));
_v_startupinfo.cb = sizeof(STARTUPINFO);
if (!CreateProcess(NULL, tszProcessPath, NULL, NULL, FALSE, 0, NULL, NULL, &_v_startupinfo, &_v_processinfo));
{
return 0x12;
}
return 0x08;
}
But cannot pass CreateProcess(NULL, tszProcesPath, /*...*/)
function on debug
mode.
Error like this;
What's wrong on my code? Is it because I created the Console Project?
if look for definition of
CreateProcess
we can note that lpCommandLine defined as In-out parameter and defined not as const pointer ( compare with lpApplicationName which is const pointer LPCTSTR)
and :
but you exactly pass literal string
_T("_background_manipulator.exe")
as lpCommandLine. and got excepted result - memory could not be written