VB6 Callback from C#
Date: 09.24.10 - 3:16pm
Did a little bit of googling on this, but all i seemed to find is info about C# callbacks and delegates.
In this sample I take a VB6 executable, call a C# COM dll, and then send execution back from the C# dll to a function within the VB6 executable as a call back.
This technique is quite useful when the called code does some kind of list building or parsing and has to send notifications back to the parent process while it is processing.
The easiest way i could think of to do this, was to use the VB6 addressof operator to pass a function address to the C# code. The CSharp code then uses the CallWindowProc API to send the notification message back to the VB6 function. And you dont even have to use /unsafe.
Even though you are limited to a specific function prototype, using Marshal.GAlloc, Marshal.Copy and CopyMemory from VB this shouldnt really be much of a limitation at all!