Platform Invoke (pinvoke)
-
Hi, I'm trying to call a method that resides in a .DLL that was built with the Watcom C/C++ 10.6 compiler. The method was exported and the compiler gave it the modifies my name with an underscore and stack length. IE: ProcAuthorizationWeb becomes _ProcAuthorizationWeb@4 because it accepts a 4 byte pointer. I have the following code setup:
[DllImport("mcp.dll")] public static extern bool _ProcAuthorizationWeb(ref CreditCardStruct CreditCardStruct); ..... _ProcAuthorizationWeb(ref CreditCardStruct);
But I get the following error: [EntryPointNotFoundException: Unable to find an entry point named _ProcAuthorizationWeb in DLL mcp.dll.] The compiler is exporting it as _ProcAuthorizationWeb@4 so I thought I might create an export alias via: '_ProcAuthorizationWeb'='_ProcAuthorizationWeb@4' in the Linker/Binder, but that gave the same error. If I put the @4 at the end of the exported name, the .NET compiler gives me an error. Any ideas on how to call the method within the .DLL? Is there a way to see the actual exported names in the .DLL? Thank you, Glenn -
Hi, I'm trying to call a method that resides in a .DLL that was built with the Watcom C/C++ 10.6 compiler. The method was exported and the compiler gave it the modifies my name with an underscore and stack length. IE: ProcAuthorizationWeb becomes _ProcAuthorizationWeb@4 because it accepts a 4 byte pointer. I have the following code setup:
[DllImport("mcp.dll")] public static extern bool _ProcAuthorizationWeb(ref CreditCardStruct CreditCardStruct); ..... _ProcAuthorizationWeb(ref CreditCardStruct);
But I get the following error: [EntryPointNotFoundException: Unable to find an entry point named _ProcAuthorizationWeb in DLL mcp.dll.] The compiler is exporting it as _ProcAuthorizationWeb@4 so I thought I might create an export alias via: '_ProcAuthorizationWeb'='_ProcAuthorizationWeb@4' in the Linker/Binder, but that gave the same error. If I put the @4 at the end of the exported name, the .NET compiler gives me an error. Any ideas on how to call the method within the .DLL? Is there a way to see the actual exported names in the .DLL? Thank you, GlennHi, You can do this. [DllImport("mcp.dll", EntryPoint="_ProcAuthorizationWeb@4", SetLastError=true)] internal static extern bool _ProcAuthorizationWeb(ref CreditCardStruct CreditCardStruct); Hope it helps. Cheers. Regards, Chua Wen Ching Visit us at http://www.necoders.com