IPC Thru WM_COPYDATA
-
Hi I have been having intermittent problems notifying a child window process with SendMessage So I decided to go with the Microsoft Sanctioned way WM_COPYDATA In my console Parent process I do GetConsoleWindow (which I observe returns what seems a valid HWND), I declare a COPYDATASTRUCT member on the stack (locally) and do SendMessage I have gotten the child window HWND with FindWindow in my MFC child window I have a messagemap entry and nothing it never gets there I am running under both the console app and the MFC app under Visual studio debugger so I can see what's going on
ON_MESSAGE(WM_COPYDATA,Debug_it)
-
Hi I have been having intermittent problems notifying a child window process with SendMessage So I decided to go with the Microsoft Sanctioned way WM_COPYDATA In my console Parent process I do GetConsoleWindow (which I observe returns what seems a valid HWND), I declare a COPYDATASTRUCT member on the stack (locally) and do SendMessage I have gotten the child window HWND with FindWindow in my MFC child window I have a messagemap entry and nothing it never gets there I am running under both the console app and the MFC app under Visual studio debugger so I can see what's going on
ON_MESSAGE(WM_COPYDATA,Debug_it)
See the first comment at WM_COPYDATA message (Windows)[^]:
Quote:
Starting with Windows Vista, the application that is to receive the WM_COPYDATA message must call the ChangeWindowMessageFilterEx function. Otherwise the the message will not be received. It will be blocked by UIPI.
-
Hi I have been having intermittent problems notifying a child window process with SendMessage So I decided to go with the Microsoft Sanctioned way WM_COPYDATA In my console Parent process I do GetConsoleWindow (which I observe returns what seems a valid HWND), I declare a COPYDATASTRUCT member on the stack (locally) and do SendMessage I have gotten the child window HWND with FindWindow in my MFC child window I have a messagemap entry and nothing it never gets there I am running under both the console app and the MFC app under Visual studio debugger so I can see what's going on
ON_MESSAGE(WM_COPYDATA,Debug_it)
I am not sure the copydata can be local but for safety I would just use globalalloc anyhow
HGLOBAL hgbl = GlobalAlloc(GMEM_ZEROINIT, sizeof(COPYDATASTRUCT) ); // Allocate the global memory
COPYDATASTRUCT* cpd = (COPYDATASTRUCT*)GlobalLock(hgbl); // Lock the allocated memory to a pointer//..... use an abuse the pointer .. when you are done
GlobalUnlock(hgbl); // Release lock on the memory block
// Reciever then locks and plays and unlocks
// ......zzzz sometime later one of the two parties
GlobalFree(hgbl); // Free the allocated memory
Not sure it's the problem but at least then when know the memory passed is valid to both parts.
In vino veritas
-
See the first comment at WM_COPYDATA message (Windows)[^]:
Quote:
Starting with Windows Vista, the application that is to receive the WM_COPYDATA message must call the ChangeWindowMessageFilterEx function. Otherwise the the message will not be received. It will be blocked by UIPI.
Thanks for your help I just tried
ChangeWindowMessageFilterEx
I got a FALSE GetLastError returned ERROR_ACCESS_DENIED This is because my process is at SECURITY_MANDATORY_LOW_RID AnyWay I can Change this. Thing is I understand the concern for security however I (my process ) created the child process so I should be able and send messages
-
Thanks for your help I just tried
ChangeWindowMessageFilterEx
I got a FALSE GetLastError returned ERROR_ACCESS_DENIED This is because my process is at SECURITY_MANDATORY_LOW_RID AnyWay I can Change this. Thing is I understand the concern for security however I (my process ) created the child process so I should be able and send messages
It's not a problem of sending messages but of receiving. So the only solution would be increasing the UIPI level of your MFC application or using another IPC method.
-
It's not a problem of sending messages but of receiving. So the only solution would be increasing the UIPI level of your MFC application or using another IPC method.
-
It's not a problem of sending messages but of receiving. So the only solution would be increasing the UIPI level of your MFC application or using another IPC method.
-
Many, many years ago I wrote a very simple app to demonstrate the use of WM_COPYDATA with MFC and I see that it is still online : Inter-Process Communication Using WM_COPYDATA[^] I rebuilt it just now in VS2015 (with very little effort) and it still works on W10. You might want to have a look at it as an example.
-
Many, many years ago I wrote a very simple app to demonstrate the use of WM_COPYDATA with MFC and I see that it is still online : Inter-Process Communication Using WM_COPYDATA[^] I rebuilt it just now in VS2015 (with very little effort) and it still works on W10. You might want to have a look at it as an example.
I originally had the WM_COPYDATA as a ON_MESSAGE message map handler than I noticed the OnCopyData I wasn't able to get it to work with that as well My current method works fine as I don't have to wait for a reply with the SetEvent and shared storage thanks for your help