LoadLibrary using the full path, not just the file name

This is a discussion on LoadLibrary using the full path, not just the file name within the Windows Programming forums, part of the Platform Specific Boards category; let me explain, because the last person who asked this got flamed for some reason about using a dll for ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    Code:
     if(hInstLibrary == NULL)
        {
            FreeLibrary(hInstLibrary);
    Poinless to call FreeLibrary on the NULL handle
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21