• 12
• 27
• 9
• 9
• 20

# DLL in diferent directory

This topic is 4858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Yes, I have searched, and I found stuff about LoadLibrary() and FreeLibrary().... Here is my code:
#include <windows.h>
#include "gamex86/CGame.h"

#pragma comment(lib, "gamex86.lib")

using namespace Narcotik;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)	{
char szBuff[MAX_PATH+64];

GetModuleFileName(NULL,szBuff,MAX_PATH);
char* psz = strrchr(szBuff,'\\');
if(psz) psz[1] = '\0';
strcat(szBuff,"/base/gamex86.dll");

CGame game;
game.run();

FreeLibrary(hm);
return 0;
}


But I still get "cannot find DLL gamex86.dll" message.... Waht have I done wrong?

##### Share on other sites
Interesting. Try replacing / with \\.

Kuphryn

##### Share on other sites
nope, that didnt work

but thanks for the suggestion!

##### Share on other sites
Try to replace
strcat(szBuff,"/base/gamex86.dll");

with
strcat(szBuff,"base\\gamex86.dll");

##### Share on other sites
"\" is an escape character, which means whatever cmoes after it is treated as ascii and not some inbuilt command, so \\ will result in compiler putting in \ ...

##### Share on other sites
I'm sure he knows that, I do as well... I just wanted to remove the initial slash.

Also, try putting MessageBox(NULL, szBuff, NULL, 0); before loading the library, it will show you the exact path it's trying to load it from. Maybe you'll see what's wrong this way.

##### Share on other sites
I did strcat(szBuff,"base\\gamex86.dll"); and the directory shows up the way it is supposed to be on the MessageBox()

But it still doesnt work?

##### Share on other sites
strcat(szBuff,".\\base\\gamex86.dll");

Who knows? :)

##### Share on other sites
You appear to be linking to that dll statically:
#pragma comment(lib, "gamex86.lib")

In which case you cannot change the path. It must be in the working directory or system directories, or path directories.

edit - Remove that line and just load the dll dynamically.