Archive for

C# Interop : How to return a VARIANT from an Unmanaged Function

1. To return a VARIANT from an unmanaged API, it must be returned as a VARIANT pointer and the equivalent C# declaration for the API must indicate a return type of IntPtr. For example : __declspec(dllexport) VARIANT* __stdcall¬†MyFunction(); The C# declaration for MyFunction() would be something like : [DllImport(@”MyDLL.dll”, CallingConvention = CallingConvention.StdCall)] static extern IntPtr … Continue reading