Loading DLL and calling methods

  • Thread starter Thread starter Festus Hagen
  • Start date Start date
F

Festus Hagen

Guest
Hi all,

I have a device that I'm trying to gain access to in C#, the manufacture provides a dll.

They are not very helpful with it's use, in fact downright rude, the extent of help is the following with a warning that disclosing proprietary information is a violation of terms of use.

So, it is slightly modified to hide their proprietary information.


typedef short (CALLBACK* GetID)(unsigned short a1, unsigned short *a2);
HINSTANCE dllHandle = NULL;
GetID pGetID = NULL;
dllHandle = LoadLibrary("device.dll");
pGetID = (GetID)GetProcAddress(dllHandle, "?GetID@CDevice@@AEJGQZPOG@Z");
unsigned short returnValue = pGetID(node, &ID);

I've tried using reflection following several different online examples however I am unable to figure out the Class Name, the Method Name or the second Invoke parameter, the array of parameters (/* parameters go here */).


I suspect the Invoke parameter array is,
m.Invoke(null, new object[] { node, &ID });
though unsure.

Assembly assembly = Assembly.LoadFile("device.dll");
Type type = assembly.GetType("Can't figure this out");
MethodInfo method = type.GetMethod("Can't figure this out");
method.Invoke(null, new object[] { /* parameters go here */ });

Help would be much appreciated.

Thank you!

Continue reading...
 
Back
Top