Re: How to pass a object to another exe as a commandline arg?
<doublemaster007@gmail.com> wrote in message
news:dd88ad42-cfa3-44fb-889c-2511737d7534@v4g2000hsf.googlegroups.com
i want to pass a struct or object to another process by commanline..
Command line is just a string of text. You can serialize your object
into a string (say, pass each field as a separate command line switch),
or choose some other method of inter-process communication.
so i tried reinterpret_casting struct/obj to TChar..
What i did was..In a COM project
typedef struct Temp
{
int num;
int num2;
}Temp;
Temp *t1=new Temp;
t1->num 0;
t1->num2=400;
TCHAR *arg= reinterpret_cast<TCHAR *>(t1);
then creating process
CreateProcess(path,arg,0,0,FALSE,DETACHED_PROCESS, 0,
0,&sStartupInfo, &pProcessInfo ))
A string is terminated by the first NUL character (a character with the
code of zero). In your case, the very first byte is NUL, so you are in
effect passing an empty string.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925