Introduction
The .NET framework provides us with a service called Platform Invoke. This service enables managed code to call unmanaged functions implemented in dynamic link libraries (DLLs), such as those in the Win32 API. It locates and invokes an exported function and marshals its arguments (integers, strings, arrays, structures, and so on) across the interoperation boundary, as needed.
However, many unmanaged functions expect you to pass, as a parameter to the function, members of structures (user-defined types in Visual Basic) that are defined in managed code. When passing structures to unmanaged code using platform invoke, you must provide additional information to preserve the original layout and alignment.
For more information, see « A closer look at Platform Invoke » on MSDN.
What is TypTrans?
Typtrans is a free command-line utility that helps you to translate C/C++ enumerations, unions and structures into C# and VB.NET code. This little utility can make you save a considerable amount of time leveraging .NET in your current environment.
Features
I have provided a sample header file (sample.h) that will demonstrate what can be accomplished with TypTrans. If your questions about using this tool have not been answered here, please Email me at support@advover.com.
Syntax
TypTrans [-v] [-s] [-t:synsfile] srcfile [destfile]
The file sample.h.cs was generated by using the following command:
TypTrans -t:wintyp.syn sample.h
Disclaimer
TYPTRANS is contributed «AS IS », with no warranties of any kind, including warranties of merchantability and fitness for a particular purpose.
Conclusion
I welcome your suggestions about this tool. If you find it useful or if you find a bug, please let me know. Enjoy !