VB6 Callback from C#


Author: Dave
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!

Download Sample




Comments: (0)

 
Leave Comment:
Name:
Email: (not shown)
Message: (Required)
Math Question: 73 + 89 = ? followed by the letter: J 



About Me
More Blogs
Main Site
Posts: (All)
2020 ( 2 )
2019 ( 5 )
2018 ( 6 )
2017 ( 6 )
2016 ( 22 )
2015 ( 16 )
2014 ( 25 )
2013 ( 4 )
2012 ( 10 )
2011 ( 7 )
2010 (11)
     Dll Not Found in IDE
     Advanced MSScript Control
     random tip
     Clipart / Vector Art
     VB6 Callback from C#
     Binary data from VB6 to C#
     CSharp and MsScriptControl
     HexDumper functions
     Js Beautify From VB6 or C#
     vb6 FormPos
     Inline Asm w VB6
2009 (3)
     The .NET Fiasco
     One rub on computers
     Universal extractor