How to pass a Structure to CreateProcess as CommnadLine parameter?
-
Hi all, While i use CreateProcess( LPCWSTR pszImageName, LPCWSTR pszCmdLine, LPSECURITY_ATTRIBUTES psaProcess, LPSECURITY_ATTRIBUTES psaThread, BOOL fInheritHandles, DWORD fdwCreate, LPVOID pvEnvironment, LPWSTR pszCurDir, LPSTARTUPINFOW psiStartInfo, LPPROCESS_INFORMATION pProcInfo ); I want to pass a structure as second parameter(pszCmdLine) in this function. But somehow child process can't correctly get the structure! Should i do anything like "cast" or.. before i pass it? thanks for any advice!
-
Hi all, While i use CreateProcess( LPCWSTR pszImageName, LPCWSTR pszCmdLine, LPSECURITY_ATTRIBUTES psaProcess, LPSECURITY_ATTRIBUTES psaThread, BOOL fInheritHandles, DWORD fdwCreate, LPVOID pvEnvironment, LPWSTR pszCurDir, LPSTARTUPINFOW psiStartInfo, LPPROCESS_INFORMATION pProcInfo ); I want to pass a structure as second parameter(pszCmdLine) in this function. But somehow child process can't correctly get the structure! Should i do anything like "cast" or.. before i pass it? thanks for any advice!
How do you plan to pass the data of the structure ? You can't just pass a pointer to the second process because the pointer is only valid in the context of the original process. I think you need to pass the value of each member of the structure as a text string to the second process and it must parse the values and "re-assemble" the data structure.
-
Hi all, While i use CreateProcess( LPCWSTR pszImageName, LPCWSTR pszCmdLine, LPSECURITY_ATTRIBUTES psaProcess, LPSECURITY_ATTRIBUTES psaThread, BOOL fInheritHandles, DWORD fdwCreate, LPVOID pvEnvironment, LPWSTR pszCurDir, LPSTARTUPINFOW psiStartInfo, LPPROCESS_INFORMATION pProcInfo ); I want to pass a structure as second parameter(pszCmdLine) in this function. But somehow child process can't correctly get the structure! Should i do anything like "cast" or.. before i pass it? thanks for any advice!
The command line parameter is a string. Because it's a wide string, each character is two bytes. You should pass the parts of the struct as a comma seperated string and rebuild it in the process. Christian Graus - Microsoft MVP - C++
-
How do you plan to pass the data of the structure ? You can't just pass a pointer to the second process because the pointer is only valid in the context of the original process. I think you need to pass the value of each member of the structure as a text string to the second process and it must parse the values and "re-assemble" the data structure.
gosh - it didn't occur to me that he could be trying to pass a pointer :-) Christian Graus - Microsoft MVP - C++
-
gosh - it didn't occur to me that he could be trying to pass a pointer :-) Christian Graus - Microsoft MVP - C++
-
I don't know - I try to assume literal interpretations of questions. I could easily be wrong. ;) I guess another option for him is WM_COPYDATA.
I also assumed they wanted to pass data or a pointer to some data.
-
Hi all, While i use CreateProcess( LPCWSTR pszImageName, LPCWSTR pszCmdLine, LPSECURITY_ATTRIBUTES psaProcess, LPSECURITY_ATTRIBUTES psaThread, BOOL fInheritHandles, DWORD fdwCreate, LPVOID pvEnvironment, LPWSTR pszCurDir, LPSTARTUPINFOW psiStartInfo, LPPROCESS_INFORMATION pProcInfo ); I want to pass a structure as second parameter(pszCmdLine) in this function. But somehow child process can't correctly get the structure! Should i do anything like "cast" or.. before i pass it? thanks for any advice!
Generate a new GUID. Make a memory mapped file (MMF) using this GUID as its name. Pass this name as a command line argument to the new process. Open the MMF from the second process and read your data from the MMF.