c++ - Problem with passing object as an argument to createProcess -
c++ - Problem with passing object as an argument to createProcess -
i trying right programme makes other programs createproces
call.
the problem when pass object of brick
class parameter of createprocess
call.
i create object (in main) way:
char ipapplicationname[1000]; startupinfo startinfo; process_information processinfo; strcpy(ipapplicationname, "c:\\documents , settings\\eigenaar\\bureaublad\\bluetoothtestr\\recvproc\\bin\\debug\\recvproc.exe"); //set nxt connection *connection = new bluetooth(); brick *nxt = new brick(connection); char *nxt_ptr = (char *)&nxt;
then connect (6
comm port of bluetooth dongle):
connection->connect(6); createprocess(ipapplicationname, nxt_ptr, null, null, false, create_new_console, null, null, &startinfo, &processinfo);
this works fine think, problem when cast char*
brick
class in recvproc.exe
process this:
brick *nxt = (brick*)argv[0];
if comment this, programme works fine... wrong line? or need pass connection object in createprocess
?
you passing, command line argument, pointer pointer class. broken in quite few ways:
createprocess's lpcommandline argument takes text string. there cannot embedded nul bytes. there must nul byte mark end of string. no such guarentee nowadays pointer-to-a-pointer, or indeed pointer or any sort of non-text-data in general. even if pointer, miracle, passed new process, new process has own address space. cannot utilize pointers old process, @ all; meaningless in process different created. argument meaningless. even if access old process's address space, there nil stopping pointed-to brick beingness destroyed before new process completes work. even if these fixed, you're passing pointer-to-a-pointer-to-a-brick, , trying utilize regular pointer-to-a-brick.in short, can't pass objects command-line arguments. text.
so, do here? here options:
have kid process connect brick on own. don't seek pass connection. set protocol of sort (over stdin/stdout, or perchance dcom) allow kid process remote command brick object in parent. makerecvproc
dll runs within parent process. c++ bluetooth createprocess nxt
Comments
Post a Comment