visual studio 2010 - C++ CreateProcess() function cannot run. Error The memory could not be written -
this question has answer here:
- createprocess() fails access violation 3 answers
i'm using windows 8 x64 enterprise, vs2010.
i've problem on createprocess().
i've create win32 console project execute _backround_manipulator.exe, 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 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 this;
what's wrong on code? because created console project?
i appreciate help.
if definition of createprocess
bool winapi createprocess( _in_opt_ lpctstr lpapplicationname, _inout_opt_ lptstr lpcommandline, ... we can note lpcommandline defined in-out parameter , defined not const pointer ( compare lpapplicationname const pointer lpctstr)
and :
the unicode version of function, createprocessw, can modify contents of string. therefore, parameter cannot pointer read-only memory (such const variable or literal string). if parameter constant string, function may cause access violation.
but pass literal string _t("_background_manipulator.exe") lpcommandline. , got excepted result - memory not written

Comments
Post a Comment