Carga de funciones de una DLL
Publicado por J Oliver Beltran (166 intervenciones) el 18/02/2004 13:13:50
Hola, estoy intentando cargar funciones de una dll ya hecha, pero tengo un problema de casting. Segun el manual de la dll el siguiente codigo deberia funcionar:
BOOL (*Inicializar)(void);
BOOL (*Cerrar)(void);
DWORD (*RealizarInquiry)(int TID,int Lun,int Host,char *Buffer,int lng);
BOOL (*RealizarRW)(int TID, int Lun, int Host,bool RW,char *Buffer,int lng,int SectorFisico,int NumeroSectores);
BOOL (*SOSoportado)(void);
fnCargaLibreriaHandyDLL(dll)
SOSoportado=GetProcAddress(dll,"fnSistemaOperativoSoportado");
RealizarRW=GetProcAddress(dll,"fnRealizarLecturaEscritura");
RealizarInquiry = GetProcAddress(dll,"fnRealizarInquiry");
Cerrar = GetProcAddress(dll,"fnCerrarConjuntoDiscos");
Inicializar = GetProcAddress(dll,"fnInicializarConjuntoDiscos");
Esto da un fallo de casting, ya que GetProcAddress devuelve un FARPROC. Alvaro me ha sugerido hacer algo como esto:
typedef BOOL (*Inicializar)(void) Init; // y luego hacer la llamada como
Inicializar = (Init)GetProcAddress(dll,"fnInicializarConjuntoDiscos");
pero me da fallo en la definicion del tipo.
Estoy usando VC++ .Net. A ver si alguien puede echarme una manilla, aunque sea al cuello :P.
BOOL (*Inicializar)(void);
BOOL (*Cerrar)(void);
DWORD (*RealizarInquiry)(int TID,int Lun,int Host,char *Buffer,int lng);
BOOL (*RealizarRW)(int TID, int Lun, int Host,bool RW,char *Buffer,int lng,int SectorFisico,int NumeroSectores);
BOOL (*SOSoportado)(void);
fnCargaLibreriaHandyDLL(dll)
SOSoportado=GetProcAddress(dll,"fnSistemaOperativoSoportado");
RealizarRW=GetProcAddress(dll,"fnRealizarLecturaEscritura");
RealizarInquiry = GetProcAddress(dll,"fnRealizarInquiry");
Cerrar = GetProcAddress(dll,"fnCerrarConjuntoDiscos");
Inicializar = GetProcAddress(dll,"fnInicializarConjuntoDiscos");
Esto da un fallo de casting, ya que GetProcAddress devuelve un FARPROC. Alvaro me ha sugerido hacer algo como esto:
typedef BOOL (*Inicializar)(void) Init; // y luego hacer la llamada como
Inicializar = (Init)GetProcAddress(dll,"fnInicializarConjuntoDiscos");
pero me da fallo en la definicion del tipo.
Estoy usando VC++ .Net. A ver si alguien puede echarme una manilla, aunque sea al cuello :P.
Valora esta pregunta


0