Reputation: 343
There are three files lay at с:/catalog. They are lib.dll, conf.ini,libImp.cpp. And I call lib.dll "init" function in libImp.cpp file. For success call of "init" function it is necessarily to have conf.ini laying in the same directory. The issue is if I try to call the dll function from another directory, the error appears. It says that it doesn`t see conf.ini. For example, if libImp.cpp located at the c:/catalog2, then that error appears. The part of code, which responds for call dll function:
HINSTANCE hGetProcIDDLL = LoadLibrary("c:\\catalog\\lib.dll");
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"init");
typedef int (__stdcall * pICFUNC)(char *);
pICFUNC init;
init = pICFUNC(lpfnGetProcessID);
bool result = 0;
char user_id[]="user";
result = init(user_id);
How to make function call independently of the cpp file location?
Upvotes: 0
Views: 378
Reputation: 179819
You're mixing concepts.
.cpp files are used as input for the compiler, and cannot be executed themselves. It doesn't matter whether the input file libImp.cpp
is located in c:\catalog\
. It might matter where the compiler output (an .EXE I assume?) ends up.
The location of the .INI file is determined by the code in the DLL. It's loading the INI file, so it determines where to look for the INI file. We cannot guess where it's looking. A tool like SysInternals ProcMon can be used to monitor the DLL and check where it's looking.
Upvotes: 1