Description of unmanaged exposed dll functions

  • Thread starter Thread starter jayderk
  • Start date Start date
J

jayderk

I can not seem to find the thread that described how to expose the functions
of functions that are usable in an unmanaged dll? any help would be great



regards,
Jay
 
I use dumpbin.exe -exports "C:\Computer\Programs\MyUnmanaged.dll"

If it is a C++ DLL, you may have to access the functions by ordinal. If it
is C, you should be able to access them by name.
You'll have to use P/Invoke (Platform Invoke) to call the functions. Once
you declare the function as shown below,
you can call it as you would any other C# method. If the unmanaged functions
have tricky parameters, you'll have to
study up a bit on P/Invoke to figure out which .NET types to substitute for
the unmanaged parameter types.

//example for C++ name mangling -- use ordinal as shown with # prefix
[DllImport("MyUnmanaged.dll", EntryPoint="#46")]
private static extern void MyExportedMethodOrdinal46(int k);

//example for unmangled names (C style)
[DllImport("MyUnmanaged.dll", EntryPoint="SetSpecialTreatment")]
private static extern void SetSpecialTreatment(int action);
 
Back
Top