I imported a dll file named swedll64.dll in main function of a c++ program how can i build a class for imported methods?in other word where should i put this codes in class ? Is there another tricks to do so like Dllimport() and extern in c#?
#include<iostream>
#include<math.h>
#include<windows.h>
using namespace std;
typedef double(*_swe_julday)(int, int, int, double, int);
typedef int(*_swe_calc)(double, int, int, double[], char[]);
typedef void(*_swe_revjul)(double, int, int&, int&, int&, double&);
int main()
{
HINSTANCE hInst = LoadLibrary(L"C:\\swedll64.dll");
_swe_julday swe_julday = reinterpret_cast<_swe_julday>(GetProcAddress(hInst, "swe_julday"));
_swe_calc swe_calc = reinterpret_cast<_swe_calc>(GetProcAddress(hInst, "swe_calc"));
_swe_revjul swe_revjul = reinterpret_cast<_swe_revjul>(GetProcAddress(hInst, "swe_revjul"));
return 0;
}
I add this simple code below for C#.this is exactly what i want to do in c++
public class Swisseph
{
Swisseph() { }
~Swisseph() { }
[DllImport("swedll64.dll", CharSet = CharSet.Ansi, EntryPoint = "swe_julday")]
private extern static double _swe_julday(int year, int month, int day, double hour, int gregflag);
public static double swe_julday(int year, int month, int day, double hour)
{
return _swe_julday(year, month, day, hour, 1);
}
}