如何实现进程间传递消息和参数?第一个问题:传递参数,需要传递很多的参数,如 name sex age等等
我用 BOOL CreateProcess(
LPCTSTR lpApplicationName,
// pointer to name of executable module
LPTSTR lpCommandLine, // pointer to command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // process security attributes
LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes
BOOL bInheritHandles, // handle inheritance flag
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // pointer to new environment block
LPCTSTR lpCurrentDirectory, // pointer to current directory name
LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION
);
生成新的进程,但是他只能用 LPTSTR lpCommandLine, 来传递一个命令行参数而已,我想把需要传递的参数定义成一个结构 struct param {char name[10],bool sex,int age ....},以便新的进程能容易找到 各个元素。但是这样好像不行哦 就是不能把结构强制转换成 LPTSTR 哦。LRESULT SendMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
z中的 WPARAM wParam,好像可以随便由其他类型转换过来,在接受消息的地方再翻转过来。但是
windef.h中是这样定义的
/* Types use for passing & returning polymorphic values */
typedef UINT WPARAM;
typedef LONG LPARAM;
typedef LONG LRESULT;
他是如何实现的呢?怎么可以随便把其他类型的数据强制转换成UINT?
第二个问题 :进程之间如何传递消息,甚至一个进程去控制另外一个进程?这个问题好像比较经典,小弟太菜,有劳大侠指点。谢谢
我用 BOOL CreateProcess(
LPCTSTR lpApplicationName,
// pointer to name of executable module
LPTSTR lpCommandLine, // pointer to command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // process security attributes
LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes
BOOL bInheritHandles, // handle inheritance flag
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // pointer to new environment block
LPCTSTR lpCurrentDirectory, // pointer to current directory name
LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION
);
生成新的进程,但是他只能用 LPTSTR lpCommandLine, 来传递一个命令行参数而已,我想把需要传递的参数定义成一个结构 struct param {char name[10],bool sex,int age ....},以便新的进程能容易找到 各个元素。但是这样好像不行哦 就是不能把结构强制转换成 LPTSTR 哦。LRESULT SendMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
z中的 WPARAM wParam,好像可以随便由其他类型转换过来,在接受消息的地方再翻转过来。但是
windef.h中是这样定义的
/* Types use for passing & returning polymorphic values */
typedef UINT WPARAM;
typedef LONG LPARAM;
typedef LONG LRESULT;
他是如何实现的呢?怎么可以随便把其他类型的数据强制转换成UINT?
第二个问题 :进程之间如何传递消息,甚至一个进程去控制另外一个进程?这个问题好像比较经典,小弟太菜,有劳大侠指点。谢谢
2.用socket
3.用文件方式
2.用socket
3.用文件方式
2.用socket
3.用文件方式