I have built a wrapper class in vc++6 that loads the DLL, Registers the reg code and has the commands I use using the load libary function. a small sample of the code is below.
First create a data type for each command argument
the syntax is typdef return value (CALLBACK* type name)(input values);
typedef long (CALLBACK* ISED_Oint_PTR)(); typedef long (CALLBACK* ISED_Oint_Iint_PTR)(long); typedef long (CALLBACK* ISED_Oint_Ichar_PTR)(char *); typedef long (CALLBACK* ISED_Oint_Ichar_Iint_PTR)(char *, long); typedef long (CALLBACK* ISED_Oint_Iddddiii_PTR)(double, double, double, double, long, long, long); typedef long (CALLBACK* ISED_Oint_Iddd_PTR)(double, double, double);
Next declare the commands in a class
class CSECiSEDDLL { public: //Methods CSECiSEDDLL(); ~CSECiSEDDLL(); //Data long ErrorCode; bool Loaded; bool UnLocked; ISED_Oint_PTR NewDocument; ISED_Oint_Iint_PTR SetOrigin; ISED_Oint_Iint_PTR SetMeasurementUnits; ISED_Oint_Ichar_PTR SetPageSize;
private: //Methods void Unlock(); void Init(); //Data HINSTANCE DLL_Handle; // Handle to DLL string UnlockCode; ISED_Oint_Ichar_PTR UnlockKey;
};
Now code the class remember that the commands in the DLL are all prefaced with iSED
//start wrapper CSECiSEDDLL::CSECiSEDDLL() { UnLocked = false; Loaded = false; Init(); UnlockCode = "XXXXXXXXXXXXX"; Unlock(); }
CSECiSEDDLL::~CSECiSEDDLL() { FreeLibrary(DLL_Handle); }
void CSECiSEDDLL::Unlock() { int errorcode; errorcode = UnlockKey (const_cast <char *> (UnlockCode.c_str())); if (errorcode != 0) { UnLocked = true; } }
void CSECiSEDDLL::Init() { DLL_Handle = LoadLibrary("iSEDQuickPDF.dll"); if (DLL_Handle != NULL) { ErrorCode = 0; Loaded = true;
UnlockKey = (ISED_Oint_Ichar_PTR)GetProcAddress(DLL_Handle,"iSEDUnlockKey"); NewDocument = (ISED_Oint_PTR)GetProcAddress(DLL_Handle,"iSEDNewDocument"); SetOrigin = (ISED_Oint_Iint_PTR)GetProcAddress(DLL_Handle,"iSEDSetOrigin"); SetMeasurementUnits = (ISED_Oint_Iint_PTR)GetProcAddress(DLL_Handle,"iSEDSetMeasurementUnits"); SetPageSize = (ISED_Oint_Ichar_PTR)GetProcAddress(DLL_Handle,"iSEDSetPageSize"); NewPages = (ISED_Oint_Iint_PTR)GetProcAddress(DLL_Handle,"iSEDNewPages"); SelectPage = (ISED_Oint_Iint_PTR)GetProcAddress(DLL_Handle,"iSEDSelectPage"); AddImageFromFile = (ISED_Oint_Ichar_Iint_PTR)GetProcAddress(DLL_Handle,"iSEDAddImageFromFile"); SaveToFile = (ISED_Oint_Ichar_PTR)GetProcAddress(DLL_Handle,"iSEDSaveToFile"); } }
To use declare an instance of the wrapper and use the commands
CSECiSEDDLL ISED; long rv; rv = ISED.LoadFromFile(const_cast <char *> (filename.c_str()));
|