Simple IPC


Author: Dave
Date: 03.14.16 - 8:14am



Download Sample

Sometimes you just want a super simple and lite weight way to send data from a child process back to its parent. My usual goto is WM_COPYDATA and subclassing the parent window.

If you want to go more lite weight, you can just use SendMessage and RegisterWindowMessage, but you are limited to using numeric values and returns only.

Also subclassing carries some weight and complexity with it. For stability I usually use an external Dll to make sure it stable if the user hits the stop button in the ide and make debugging easier for the rest of the project.

If the project is a plugin, or vb ide addin..you want as little complexity as possible and maximum stability.

This made me think of a piss simple IPC mechanism that requires no subclassing and is basically error proof. You can implement it in a minute or two max.
  • parent process spawns child with argument hwnd=txtRecv.hwnd
  • child extracts hwnd from command line
  • child uses PostMessage(hwnd,WM_PASTE,0,0) with text message in clipboard
  • parent process receives the message when the normal vb txtRecv_Changed event fires.
There are other ways to get the hwnd as well, you could just as easily save it to the registry with Save/GetSetting, or you could use FindWindow api and then enum its children to find it on the fly.

no subclassing, no extra libraries, nothing fancy what so ever. Tested on XP and Win7, should be find on all others since its a base system capability.* (as long as processes have same integrity levels)




Comments: (0)

 
Leave Comment:
Name:
Email: (not shown)
Message: (Required)
Math Question: 37 + 34 = ? followed by the letter: T 



About Me
More Blogs
Main Site
Posts: (All)
2024 ( 1 )
2023 ( 9 )
2022 ( 4 )
2021 ( 2 )
2020 ( 4 )
2019 ( 5 )
2018 ( 6 )
2017 ( 6 )
2016 (22)
     VB6 CDECL
     UDT Tricks pt2
     Remote Data Extraction
     Collection Extender
     VB6 FindResource
     CDO.Message
     DirList Single Click
     Reset CheckPoint VPN Policy
     VB6 BSTR Oddities Explained
     SafeArrays in C
     BSTR and Variant in C++
     Property let optional args
     Misc Libs
     Enum Named Pipes
     Vb6 Collection in C++
     VB6 Overloaded Methods
     EXPORT FUNCDNAME Warning
     VB6 Syncronous Socket
     Simple IPC
     VB6 Auto Resize Form Elements
     Mach3 Automation
     Exit For in While
2015 ( 15 )
2014 ( 25 )
2013 ( 4 )
2012 ( 10 )
2011 ( 7 )
2010 ( 11 )
2009 ( 3 )