GetProcAddress is returning null...
I am using the latest C++ Builder from CodeGear.
There is an API.h and file1.cpp - then I show my output... no compiling problems - just keep getting null!
-------------------file1.c
pp--------
----------
---
//------------------------
----------
----------
----------
----------
----------
-
#pragma hdrstop
#pragma argsused
#pragma package(smart_init)
#include "api.h"
#include <vcl.h>
#include <iostream>
/*
* The handle for the cdbdapi Libray
*/
HMODULE hm = NULL;
/*
* Holders for DLL Imported functions
*/
TInitAPI InitAPI;
TCloseAPI CloseAPI;
TGetMeet GetMeet;
TGetTime GetTime;
TGetRace GetRace;
TResult Result;
TGetID GetID;
TLoadShadow LoadShadow;
TEngineFromSysTray EngineFromSysTray;
TEngineToSysTray EngineToSysTray;
TGetQuinella GetQuinella;
TGetExacta GetExacta;
TGetTrifecta GetTrifecta;
using namespace std;
void exit_application ( void );
//------------------------
----------
----------
----------
----------
----------
-
void exit_application ( void )
{
int t;
cin >> t;
exit (0);
}
int main(int argc, char* argv[])
{
//try to load the library, return to console if not found
if( ( hm = LoadLibrary( "C:\\Users\\Yiannis\\Deskt
op\\HR2\\c
dbdapi.dll
" ) ) == NULL )
{
cout << "LoadLibrary: DLL Could Not Be Loaded." << endl;
exit_application ();
}
else
{
cout << "LoadLibrary: DLL Loaded Fine." << endl;
}
/*
* Get the addresses for the functions being used.
*/
if((InitAPI=(TInitAPI)GetP
rocAddress
(hm,"InitA
PI"))==NUL
L)
cout << "InitAPI(): Address Not Found!" << endl;
if((CloseAPI=(TCloseAPI)Ge
tProcAddre
ss(hm,"Clo
seAPI"))==
NULL)
cout << "CloseAPI(): Address Not Found!" << endl;
if((GetMeet=(TGetMeet)GetP
rocAddress
(hm,"GetMe
et"))==NUL
L)
cout << "GetMeet(): Address Not Found!" << endl;
//if((GetTime=(TGetTime)Ge
tProcAddre
ss(hm,"Get
Time"))==N
ULL)
// cout << "GetTime(): Address Not Found!" << endl;
if((GetRace=(TGetRace)GetP
rocAddress
(hm,"GetRa
ce"))==NUL
L)
cout << "GetRace(): Address Not Found!" << endl;
if((Result=(TResult)GetPro
cAddress(h
m,"Result"
))==NULL)
cout << "Result(): Address Not Found!" << endl;
if((GetID=(TGetID)GetProcA
ddress(hm,
"GetID"))=
=NULL)
cout << "GetID(): Address Not Found!" << endl;
if((LoadShadow=(TLoadShado
w)GetProcA
ddress(hm,
"LoadShado
w"))==NULL
)
cout << "LoadShadow(): Address Not Found!" << endl;
if((EngineFromSysTray=(TEn
gineFromSy
sTray)GetP
rocAddress
(hm,"Engin
eFromSysTr
ay"))==NUL
L)
cout << "EngineFromSysTray(): Address Not Found!" << endl;
if((EngineToSysTray=(TEngi
neToSysTra
y)GetProcA
ddress(hm,
"EngineToS
ysTray"))=
=NULL)
cout << "EngineToSysTray(): Address Not Found!" << endl;
if((GetQuinella=(TGetQuine
lla)GetPro
cAddress(h
m,"GetQuin
ella"))==N
ULL)
cout << "GetQuinella(): Address Not Found!" << endl;
if((GetExacta=(TGetExacta)
GetProcAdd
ress(hm,"G
etExacta")
)==NULL)
cout << "GetExacta(): Address Not Found!" << endl;
if((GetTrifecta=(TGetTrife
cta)GetPro
cAddress(h
m,"GetTrif
ecta"))==N
ULL)
cout << "GetTrifecta(): Address Not Found!" << endl;
if ( !FreeLibrary ( hm ) ) {
cout << "FreeLibrary(): Could not unload DLL" << endl;
}
exit_application ();
return 1;
}
//------------------------
----------
----------
----------
----------
----------
-
-----------api.h--------
//A few defines not show...
typedef int _stdcall (*TInitAPI)( void );
typedef void _stdcall (*TCloseAPI)( void );
typedef int _stdcall (*TGetMeet)(char *, int *); //buf, len
typedef int _stdcall (*TGetTime)(char *, int *); //buf, len
typedef int _stdcall (*TGetRace)(char *, int *, int, char *, char *, int, int, int, int); //buf, len, refstate, meet, race, state, pool, updates, summary
typedef int _stdcall (*TGetQuinella)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TGetExacta)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TGetTrifecta)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TResult)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TGetID)(char *, int *); //buf, len
typedef int _stdcall (*TLoadShadow)(char *); //filename
typedef int _stdcall (*TEngineToSysTray)( void );
typedef int _stdcall (*TEngineFromSysTray)( void );
------end api.h-----------
My output!
LoadLibrary: DLL Loaded Fine.
InitAPI(): Address Not Found!
CloseAPI(): Address Not Found!
GetMeet(): Address Not Found!
GetRace(): Address Not Found!
Result(): Address Not Found!
GetID(): Address Not Found!
LoadShadow(): Address Not Found!
EngineFromSysTray(): Address Not Found!
EngineToSysTray(): Address Not Found!
GetQuinella(): Address Not Found!
GetExacta(): Address Not Found!
GetTrifecta(): Address Not Found!
Start Free Trial