Thread: LoadLibrary using the full path, not just the file name

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    63

    LoadLibrary using the full path, not just the file name

    let me explain, because the last person who asked this got flamed for some reason about using a dll for illegitimate purposes, although i didnt see the problem with what he was asking. Im making a program which uses a plugin like archetecture, and I want to load a dll by its path name, however

    Code:
        HINSTANCE hInstLibrary = LoadLibrary("C:\pathTo\dp_dummy.dll");
        if(hInstLibrary == NULL)
        {
            FreeLibrary(hInstLibrary);
            wxString output;
            output.Printf("didnt Load");
            logMessage(output);
            return 0;
        }
    which returns didnt load. Ive tried pleanty of variation of that, such as using double \\, ommiting the C:, but i cant figure out how to load it.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    http://msdn2.microsoft.com/en-us/library/ms684175.aspx
    Maybe call GetLastError() to find out why ?

    And yes, you'll need \\
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
     if(hInstLibrary == NULL)
        {
            FreeLibrary(hInstLibrary);
    Poinless to call FreeLibrary on the NULL handle
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  3. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  4. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM