#ifndef HEADER_INFOAPI
#define HEADER_INFOAPI
#define EXTERN_C extern "C"
#define INFOAPI __declspec(dllexport)
#include <windows.h>
#include <TCHAR.h>
struct Info
{
virtual void StartPs() = 0;
virtual double GetHt() = 0;
virtual bool IsShowInfo() = 0;
};
typedef Info* INFOHANDLE;
EXTERN_C INFOAPI INFOHANDLE WINAPI GetInfo(wchar_t* File1,
wchar_t* File2,
double Height,
int Num);
#endif
I have written a DLL in dev C++. The DLL's name is "Info.dll" and it contains one functions: "GetInfo". The header file looks like this:
How do I call it in C# ?
hi, c45207
I tried what you said and got a wrong value of bodyRes.GetHt()
In my expect the bodyRes.GetHt() should be = Double test = 170.0,
but I got 9.2079039212996476E-275
Can you kindly help me to check out if anything that I did wrong?
============================= code ===============================
Double test = 170.0;
IntPtr x = GetInfo("C:\\t.jpg", "C:\\e.jpg", test, 0);
IBodyInfo bodyRes = (Info)Marshal.PtrToStructure(x, typeof(Info));
bodyRes.StartPs();
====================================================================
============================= result =============================
bodyRes.GetHt() 9.2079039212996476E-275 double
bodyRes.IsShowInfo() false bool
====================================================================