I have a C-DLL with a short documentation and I'd like to use this DLL in my C# program.
Unfortunately the documentation is for an Excel-Makro which is password-protected and so I don't know the exact function names and parameter types.
I used DependencyWalker to find all export functions of the DLL and together with the documentation I figured out that the documented function ptx is called FU_PTX in the DLL and expects one parameter and has a return value. Unfortuntely I still don't know the type of the parameter or the return value but I know that it is a number.
So I wrote following code:
...
[DllImport("dmata.dll")]
public static extern UInt32 FU_PTX(UInt32 x);
FU_PTX(11);
...
This code throws an AccessViolationException. I also tryed other types as int, long, double but I always get the same exception.
As far as I know there is no way to get the required types from the dll directly but perhaps anyone has an idea what might be wrong or can point me in the right direction.
Edit:
I managed to get the signatures from the vba-file:
Private Declare Function FU_PTX# Lib "dmata.dll" (FT#)
I ported this to following C# code:
[DllImport("dmata.dll")]
public static extern double FU_PTX(double x);
FU_PTX(1.5);
I still receive the same AccessViolationException. Anyone an idea why I still get the same exception?