Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Help with linking dll explicitly

Author
Message
frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 18th Jan 2007 01:23 Edited at: 18th Jan 2007 01:29
I'm trying to link into a dll explicitly or dynamically and my code could not find the dll. This code is taken from wikipedia for testing. Could anyone tell me what am I doing wrong? I'm using VSC++ 2005.





I appriciate the help

Oh, by the way, some of you may think that it should be HINSTANCE instead of HMODULE; But HMODULE is also type defined as HINSTANCE under winbase.h
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jan 2007 17:30
I see a mixture of ASCII and UNICODE there - is the cast to LPCWSTR really necessary in your LoadLibrary call?

frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 18th Jan 2007 18:09
I have it without the LPCWSTR before and when I try to compile, VC++2005 compiler is has an error saying that it cannot conver from char to LPCWSTR... is there an option that you can think of that deals with that?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jan 2007 18:14
No, no options - simply that your code is wrong. Instead of casting an ASCII string to UNICODE, which just tells the compiler to treat the ASCII string as if it were UNICODE, you need to actually provide a UNICODE string.



frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 18th Jan 2007 19:42
I also found a solution, by including #include<tchar.h> and putting it this way:




then it works. Thanks.
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 18th Jan 2007 19:46
IIRC, if you include <atlconv.h> as well, you can use all of the ATL string conversion functions which are pretty much portable.

This may also help as well:

http://msdn2.microsoft.com/en-us/library/ms235631(VS.80).aspx

Paul.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jan 2007 20:09
@frstPrsn, same difference. The _T macro, as well as _TEXT and TEXT effectively transform the text inside the brackets into what I posted, depending on whether the _UNICODE macro is defined or not.

frstPrsn
18
Years of Service
User Offline
Joined: 13th Apr 2006
Location:
Posted: 18th Jan 2007 20:48
ahhh ic... that makes sense... thanks for all the help

Login to post a reply

Server time is: 2024-06-28 03:01:20
Your offset time is: 2024-06-28 03:01:20