loading dll problem

Hey guys. I have never used DLLs before and I seem to be having some difficulties.

I am trying to load a dll for an API called ASPI however it seems to fail to load it no matter what. Can anyone please enlighten me? I have included some other file paths I have tried... :)

The library was installed to c:\\windows\\system32\\WNASPI32.DLL
and the documentation says it can be loaded using "hinstWNASPI32 = LoadLibrary( LPCWSTR("WNASPI32") )".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
printf("\n\nLoading ASPI library...");
	HINSTANCE hinstWNASPI32;
	
	//hinstWNASPI32 = LoadLibrary(LPCWSTR("C:\\WINDOWS\\system32\\WNASPI32.DLL"));
	//hinstWNASPI32 = LoadLibrary( LPCWSTR("WNASPI32") );
	//hinstWNASPI32 = LoadLibrary( LPCWSTR("WNASPI32.DLL") );
	hinstWNASPI32 = LoadLibrary(LPCWSTR("C:/WINDOWS/system32/WNASPI32.DLL"));
	
	if( !hinstWNASPI32 ){
		printf(" failed.");
		loadedDll = false;
	}else{
		printf(" success.");
		loadedDll = true;
	}
Last edited on
I think your force casting to a LPCWSTR is the problem here (that cast would NOT do what you want).

Instead try:
hinstWNASPI32 = LoadLibrary(L"C:/WINDOWS/system32/WNASPI32.DLL");

Notice the L in front of the string.
Last edited on
words cannot express my love for you right now :P (it worked)

I have never come across this kind of cast before. Is it just a type def?

Regards, aaron.
Topic archived. No new replies allowed.