Cargar un Dll

Ian
14 de Julio del 2004
Hola, esto tratando de cargar un dll desde un funcion en... el codigo me compila, pero a la hora de ejecutarlo ocurre cierto error (no se cual sera), y el prompt del DOS se cierra. Cualquiera que me pueda ayudar se lo agradeceria. La funcion que llama al DLL se las anexo:

#include <windows.h>

int i = 1;

int OpenPort(char *puerto, long velocidad);

typedef int (* FUNCTION1)(char *,long);

int main()
{

i = OpenPort("COM1", 57600);
return 1;
}

int OpenPort(char *puerto, long velocidad)
{


int i = 0;

HINSTANCE hinstLib;
FUNCTION1 IOpenPort;
/ Get a handle to the DLL module.
hinstLib = LoadLibrary("iclass.dll");
// If the handle is valid, try to get the function address.

if (hinstLib != NULL) // if (hinstLib != NULL)
{
IOpenPort = (FUNCTION1)GetProcAddress (hinstLib, "IOpenPort");
// If the function address is valid, call the function.

if (IOpenPort)
{
i = IOpenPort(puerto, velocidad);
// Free the DLL module.

FreeLibrary(hinstLib);
}
}
return i;

}




Alejandro_
14 de Julio del 2004
Para mí está bien.

Prueba poniendo getchar(), o algo por el estilo, antes de salir de main(), para que no se cierre la consola...

Alejandro