Quickest Way to Wrap Standard Win32 DLL?
-
All, I have a "standard" Win32 DLL with the C header. I'd like to create a Managed C++ assembly (DLL) which can be used by the other .NET languages such as C# and VB.NET. Must I write all the code manually to expose the data structures and methods? Is there a tool or utility which will allow me to do this quickly? I appreciate your help. Thanks, RB
-
All, I have a "standard" Win32 DLL with the C header. I'd like to create a Managed C++ assembly (DLL) which can be used by the other .NET languages such as C# and VB.NET. Must I write all the code manually to expose the data structures and methods? Is there a tool or utility which will allow me to do this quickly? I appreciate your help. Thanks, RB
You might take a look around over at: www.PInvoke.net If the standard Win32 DLLs were Type Libraries you could simply use the Type Library Importer to convert them to .NET assemblies (TlbImp.exe, it lives in the Program Files\Microsoft Visual Studio .NET folder). Most people just use the Win32 functions in their code by using the DllImport attribute before the function declaration. You must add the line "using namespace System::Runtime::InteropServices;" to your code, and the DLLImport attribute requires that you supply a String object, for instance, "User32.dll" as a parameter. You could, of course, do this for the entire DLL, but, it would keep you busy for awhile. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemruntimeinteropservicesdllimportattributeclasstopic.asp[^] I think the reasoning behind the Interop method has to do with Type safety by the managing CLR.