Hi,
Actually I´m a VB-programmer, but I´ve a problem that I can´t resolve with VB so I come to this C forum. I need to create a DLL witch functions I can call as flat unmanaged code. For example I want to call a method named "MyFun" in the DLL "MyDLL.DLL" that accepts an UINT32 as a value parameter, an UINT16 as e reference parameter and returns a BYTE.
In VB my call will look like this:
Declare function MyFun Lib "MyDLL.DLL" (byval A as UINT32, byref B as UINT 16) as Byte
In C# my call will look like this:
[DllImport("MyDLL.DLL")]
public static extern Byte MyFun(UInt32 A, ref UINT16 B);
Found the following text in the MSDN:
Exposing a Managed API as a Flat API
"Sometimes unmanaged clients cannot use COM. For example, they might already be written to use flat APIs and cannot be changed or recompiled. C++ is the only high-level language that allows you to expose managed APIs as flat APIs. Doing this is not as straightforward as exposing a managed API as a COM API. It is a very advanced technique that requires advanced knowledge of C++ interop and the differences between the managed and unmanaged worlds.
Expose your managed API as a flat API only if absolutely necessary. If you have no choice, be sure to check the C++ documentation and be fully aware of all the limitations."
(ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEV.v10.en/ dndotnet/html/manunmancode.htm)
The code I have to write is quite simple. I just want to write a wrapper that sends all input directly to another flat DLL. Maybe I can write everything directly in unmanaged code. The main problem is the input. I created several DLL's in C and C++ and a testprogram in VB to try if it works. Altough I tried various methods to expose MyFun I keep getting the error message "Unable to find an entry point named 'MyFun' in DLL 'MyDLL.dll'." I suppose that I´ll have to create some kind of entry point table in my DLL for this to work, but I got stuck here.
Hope that anyone can help me with this.
Actually I´m a VB-programmer, but I´ve a problem that I can´t resolve with VB so I come to this C forum. I need to create a DLL witch functions I can call as flat unmanaged code. For example I want to call a method named "MyFun" in the DLL "MyDLL.DLL" that accepts an UINT32 as a value parameter, an UINT16 as e reference parameter and returns a BYTE.
In VB my call will look like this:
Declare function MyFun Lib "MyDLL.DLL" (byval A as UINT32, byref B as UINT 16) as Byte
In C# my call will look like this:
[DllImport("MyDLL.DLL")]
public static extern Byte MyFun(UInt32 A, ref UINT16 B);
Found the following text in the MSDN:
Exposing a Managed API as a Flat API
"Sometimes unmanaged clients cannot use COM. For example, they might already be written to use flat APIs and cannot be changed or recompiled. C++ is the only high-level language that allows you to expose managed APIs as flat APIs. Doing this is not as straightforward as exposing a managed API as a COM API. It is a very advanced technique that requires advanced knowledge of C++ interop and the differences between the managed and unmanaged worlds.
Expose your managed API as a flat API only if absolutely necessary. If you have no choice, be sure to check the C++ documentation and be fully aware of all the limitations."
(ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEV.v10.en/ dndotnet/html/manunmancode.htm)
The code I have to write is quite simple. I just want to write a wrapper that sends all input directly to another flat DLL. Maybe I can write everything directly in unmanaged code. The main problem is the input. I created several DLL's in C and C++ and a testprogram in VB to try if it works. Altough I tried various methods to expose MyFun I keep getting the error message "Unable to find an entry point named 'MyFun' in DLL 'MyDLL.dll'." I suppose that I´ll have to create some kind of entry point table in my DLL for this to work, but I got stuck here.
Hope that anyone can help me with this.