//
archives

delegate

This tag is associated with 6 posts

Supporting COM Events from a Managed Class.

1. Introduction. 1.1 A COM-visible managed class can support COM events just like any COM coclass. 1.2 In this article, I aim to briefly expound on the .NET and COM event models and then zoom in on a working example which I hope will serve as a template for more complex systems, 1.3 In subsequent blog entries, I will also … Continue reading

Passing Managed Structures With Strings To Unmanaged Code Part 3

1. Introduction. 1.1 In part 1 of this series of blogs we studied how to pass a managed structure (which contains strings) to unmanaged code. The structure was passed as an “in” (by-value) parameter, i.e. the structure was passed to the unmanaged code as a read-only parameter. 1.2 Then in part 2, we studied the techniques for receiving … Continue reading

Passing Managed Structures With Strings To Unmanaged Code Part 2

1. Introduction. 1.1 In part 1 of this series of blogs we studied how to pass a managed structure (which contains strings) to unmanaged code. The structure was passed as an “in” (by-value) parameter, i.e. the structure was passed to the unmanaged code as a read-only parameter. 1.2 Here in part 2, we shall explore the … Continue reading

Programmatically Register COM Dlls in C#

1. Introduction. 1.1 Recently, someone from the MSDN forum asked for advise on how to programmatically register a COM DLL using managed code. 1.2 The answer is simple indeed : a COM DLL must export 2 APIs : DllRegisterServer() and DllUnregisterServer(). 1.3 To register the DLL, the DLL is loaded (by the registration program, e.g. … Continue reading

Delegates As Callbacks Part 2

1. Introduction. 1.1 This blog is a continuation of an earlier blog Delegates As Callbacks Part 1. 1.2 In this part 2, I shall demonstrate using managed methods as callbacks that can be invoked from unmanaged code. 2. Sample Code. 2.1 Listed below is a sample unmanaged code written in C++ : typedef void (__stdcall … Continue reading

Delegates as Callbacks Part 1

1. Introduction 1.1 A concept frequently used in real-world software development is that of a callback. 1.2 A callback, as we know, is a function which is asynchronously called, often when some event of significance occurs. 1.3 This series of blogs examines how this concept is realized between managed and unmanaged code. In this part … Continue reading