Hello guys,
I have loaded akrip32.dll and can get handle within a function, but cannot get it when calling the function in main()
Please help me
app.cpp
#include <iostream>
//testing function below
//main application
int main()
{
CDRip instance;
DWORD ver = instance.GetVersion();
LPGETCDHAND cdhandle;
HCDROM handle ;
handle = instance.GetCDHandle(cdhandle);
std::cout<<"The Handle is: "<<handle<<std::endl;
//wait!
std::cin.get();
return 0;
}
main.cpp
#include <iostream>
#include "main.h"
//Get CD handle
HCDROM CDRip::GetCDHandle(LPGETCDHAND lpcd ){
//define a pointer to the function
typedef HCDROM (*ptrGetCDHandle)(LPGETCDHAND lpcd );
//Create a pointer function to access the DLL function
ptrGetCDHandle GCDHandle;
//Load the DLL
HINSTANCE hDLL = LoadLibrary("akrip32.dll");
//DLL loaded successful?
if (hDLL!=0){
std::cout<<"Loaded DLL"<<std::endl;
//Get Function address
GCDHandle = (ptrGetCDHandle)GetProcAddress(hDLL, "GetCDHandle");
// Function loaded Succesful?
if (GCDHandle !=0){
LPGETCDHAND ptrCDHandle;
HCDROM test_handle = GCDHandle(ptrCDHandle);
return test_handle;
FreeLibrary(hDLL);
}
// Function Loading failed
else{
std::cout<<"Error, can't load function GetVersion!"<<std::endl;
FreeLibrary(hDLL);
}
}
//DLL Loading failed
else std::cout<<"Error! Cannot Load Library"<<std::endl;
}
main.h
#include <windows.h>
//structs used in below functions
#define MAXIDLEN 64
#define MAXCDLIST 8
typedef struct
{
char vendor[9];
char prodId[17];
char rev[5];
char vendSpec[21];
} CDINFO, *PCDINFO, FAR *LPCDINFO;
typedef struct
{
BYTE ha;
BYTE tgt;
BYTE lun;
BYTE pad;
char id[MAXIDLEN + 1];
CDINFO info;
} CDREC, *PCDREC, FAR *LPCDREC;
typedef struct
{
BYTE max;
BYTE num;
CDREC cd[MAXCDLIST];
} CDLIST, *PCDLIST, FAR *LPCDLIST;
typedef struct _GETCDHAND
{
BYTE size;
BYTE ver;
BYTE ha;
BYTE tgt;
BYTE lun;
BYTE readType;
BOOL jitterCorr;
BYTE numJitter;
BYTE numOverlap; // was previously numSave
} PACKED GETCDHAND, *PGETCDHAND, FAR *LPGETCDHAND;
//The TOC structure is used for calls to ReadTOC. It is essentially a direct copy of the format returned by the SCSI READ TOC (0x43) command.
typedef struct
{
BYTE rsvd;
BYTE ADR;
BYTE trackNumber;
BYTE rsvd2;
BYTE addr[4];
} PACKED TOCTRACK;
typedef struct
{
WORD tocLen;
BYTE firstTrack;
BYTE lastTrack;
TOCTRACK tracks[100];
} PACKED TOC, *PTOC, FAR *LPTOC;
//CD Handle
typedef HANDLE HCDROM;
class CDRip{
public:
//constructor
//CDRip::CDRip(){}
// Opens a handle to a CD-ROM device with the options specified in the lpcd parameter.
HCDROM GetCDHandle(LPGETCDHAND lpcd );//implement
//Just returns a handle to CDROM
HCDROM RetHandle(void);
};
Thanks