Jump to content
  • Advertisement
Sign in to follow this  
colinisinhere

DLL in diferent directory

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

If you intended to correct an error in the post then please contact us.

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");

	HMODULE hm = LoadLibrary(szBuff);

	CGame game;
	game.run();

	FreeLibrary(hm);
	return 0;
}

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

Share this post


Link to post
Share on other sites
Advertisement
"\" 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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!