Reply |
| alice johnson replied to sambath kumar at 03-Jul-08 01:32 |
Here's an example of a properly defined native Dll method written in 'C':
extern "C"
{
//Note: must use __declspec(dllexport) to make (export) methods as 'public'
__declspec(dllexport) void DoSomethingInC(unsigned short int ExampleParam, unsigned char AnotherExampleParam)
{
printf("You called method DoSomethingInC(), You passed in %d and %c\n\r", ExampleParam, AnotherExampleParam);
}
}//End 'extern "C"' to prevent name mangling
Here's what the import declaration in C# looks like:
[DllImport("C_DLL_with_Csharp.dll", EntryPoint="DoSomethingInC")]
public static extern void DoSomethingInC(ushort ExampleParam, char AnotherExampleParam);
Here's what the Dll dump looks like:
File Type: DLL
Section contains the following exports for C_DLL_with_Csharp.dll
00000000 characteristics
409557E6 time date stamp Sun May 02 13:19:50 2004
Hi please got hrough the below link: Hope they help you:
http://www.codeproject.com/KB/cs/C_DLL_with_Csharp.aspx |
|