The following simple C++ program is compiled using Digital Mars (v 8.57) and also using Visual Studio 2012 Empty C++ project type (build target 86). When I try to import the functions in a C# program, the application crashes reading the Digital Mars version but works fine using the VS version. When I run in debug mode, the function returns "Function Evaluation Was Aborted" and attempts multiple times to evaluate then stops. I'm running on Windows 7 64 bit.
C++ program:
#include <stdio.h>
#include <windows.h>
The layout of the struct_iob in stdio. h is different for Digital Mars C++. Therefore, you cannot link buffered I/ O functions compiled with Digital Mars' stdio. h with buffered I/ O functions compiled with a different stdio. h. To avoid problems, compile all modules in a program with the same version of stdio. h.
Which might have something to do with it :\ .
MIDL isn't really that hard and it solves for pesky crap like that. You should at least give it a look before reinventing the wheel.