Thread: How to import a DLL

  1. #1
    Pupil
    Join Date
    Oct 2005
    Location
    Toledo
    Posts
    27

    Question How to import a DLL

    I have no experience with dynamic link libraries. The examples my book provide use the “#using” keyword.

    i.e #using <mscorlib.dll>

    I have a .dll used for encrypting the username and password when loging into Yahoo Messenger. I copied the .dll to my project folder and used this code to link it.

    Code:
    #ifndef __login_h__
    #define __login_h__
    #using <YMSG12ENCRYPT.DLL>
    #endif
    Error:
    Code:
    fatal error C1113: #using failed on 'c:\yahoologinc\ymsg12encrypt.dll

    This also don't work
    Code:
    HMODULE hMod = LoadLibrary("YMSG12ENCRYPT.DLL");
    Error:
    Code:
    error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [18]' to 'LPCWSTR'
    I think the .dll was written in vb.

    What am I missing on this?
    Last edited by chad101; 05-30-2007 at 06:41 PM.

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    This is a Unicode problem. Call LoadLibraryA() rather than LoadLibrary().

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    > This is a Unicode problem. Call LoadLibraryA() rather than LoadLibrary().

    Or better yet, use a TEXT or _T macro to transform it to a unicode string literal:
    Code:
    HMODULE hMod = LoadLibrary(TEXT("YMSG12ENCRYPT.DLL"));
    I don't know what your first problem is, though. I think that the #using macro is something from MS Managed C++ or C++/CLI, but I'm not sure.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    Pupil
    Join Date
    Oct 2005
    Location
    Toledo
    Posts
    27
    Yea it is, “VC++.NET How to Program” is an intermediate book on managed C++. Very good book though. I never knew VC++ had a built in garbage collector (__gc) till I bought this book.

    The main problem was importing this DLL into my chat client. I found a yahoo login example online and I don’t have the code for the DLL just the login example (Written in VB.NET).

    I’m practicing network programming as my summer break project and a simple yahoo chat client would be a fun way to do this.
    Last edited by chad101; 05-31-2007 at 05:30 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dll Import
    By dankalim in forum C Programming
    Replies: 3
    Last Post: 06-29-2007, 09:37 AM
  2. DLL generated but related import library is missing?
    By George2 in forum C Programming
    Replies: 0
    Last Post: 08-18-2006, 12:13 AM
  3. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  4. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM
  5. Import Dll
    By Shakespeare in forum C++ Programming
    Replies: 2
    Last Post: 01-27-2003, 05:40 AM