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...
Hi..
i want to pass a struct or object to another process by commanline..
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 ))
then i tried retriving back the struct from other process.. only the
'num' value is preserved, num2 contains junk. second fields onwords of
the struct contains junk values...
can any one please tell me..where i am doing wrong??
Is there any other way of doing this??
An address in your process is meaningless in another process. Each process
has its own private address space. To pass parameters on the command line
you must convert the values (not addresses) into text, like "200, 400".
There are many other ways to pass data between processes, including a COM
interface, or shared memory, or pipes, or WM_COPYDATA, or sockets, ....
--
Scott McPhillips [VC++ MVP]