Thread: Fun with dll's

  1. #1
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685

    Fun with dll's

    I have a program in one directory and its DLL's in a different directory. I use LoadLibrary() to load in the libraries but I still get the dll not found message.

  2. #2
    Unregistered
    Guest
    Maybe this will help:

    When no path is specified, the function searches for loaded modules whose base name matches the base name of the module to be loaded. If the name matches, the load succeeds. Otherwise, the function searches for the file in the following sequence:

    1 The directory from which the application loaded.

    2 The current directory.

    3 Windows 95 and Windows 98: The Windows system directory. Use theGetSystemDirectory function to get the path of this directory.

    4 Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.

    5 Windows NT: The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.

    6 The Windows directory. Use theGetWindowsDirectory function to get the path of this directory.

    7 The directories that are listed in the PATH environment variable.
    The first directory searched is the one directory containing the image file used to create the calling process (for more information, see the CreateProcess function). Doing this allows private dynamic-link library (DLL) files associated with a process to be found without adding the process's installed directory to the PATH environment variable.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Have a look at;

    Code:
    HMODULE hMod = LoadLibraryEx("C:\\MyDir\\Myfile.dll",
                   NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
    That might work a little better

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Thanks for the help guys but I'm still not getting it to work.

    Here is exactly what I'm doing (possibly wrong). My dll's are implicitly linked. I've read somewhere that I could kill the missing dll message box that windows throws up using SetErrorMode() but that didn't work. So, in fact, both of your suggestions may be working but windows reports the missing dll to the user and prevents the program from starting before the program even has a chance to correct the situation. So what is my best bet in fixing this problem?

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    If you put a copy of the DLL in the exe working dir does it load correctly? (ie test it is a not found and not a fail to load error)

    Could be the DLL is failing in its DLLMain() and so looks like it can't be found.

    (you obviously have the lib needed, do you have the correct debug / release one?)

    I had heaps of trouble with a debug DLL working with my app but its release version would not. So linked explicitly with a header and a def file. The compiler was truncating the function names in release mode and so they could not be found, causing the fail to load. Because of the extra storage, the debug info, in the debug version still contained the correct function names.

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    *sigh* unfortunately--well maybe not that unfortunately the dll does work. So that means my problem lies in the directory thing. I also has some problems with the way that compiler was doing the function names but I worked my way up to this point. I guess this is a case of "another day another problem." I was reading some of ms's docs and found that in Win CE you can add a register key to allow an app to use dll's from a different directory. Can I do something like that using any other windows? (I'm using Win 98 SE)

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685

    if anyone cares

    Here is a simple answer to my problem. I'm gonna post it only because I know someone will ask the same question someday. If you make a shortcut to the program that needs the dll's that exist in a different directory you can completely by-pass the problem. You just make sure that the shortcut starts in the directory of the dll's not the exe. This way a user, or your program, won't have to add crap to the path. And even better yet you won't have to add the dll's to the windows directory. If someone has a better way i'm all ears but until then this way works.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Protection of DLLs
    By Poche in forum C# Programming
    Replies: 5
    Last Post: 06-04-2009, 08:30 PM
  2. Some doubts on DLLs
    By BrownB in forum Windows Programming
    Replies: 1
    Last Post: 05-30-2007, 02:25 AM
  3. standart dlls
    By keeper in forum C++ Programming
    Replies: 3
    Last Post: 07-05-2006, 07:32 PM
  4. Can't load string from resource DLL's string table
    By s_k in forum Windows Programming
    Replies: 4
    Last Post: 07-15-2003, 06:43 AM
  5. question about DLL's and class functions
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 02-25-2003, 06:08 AM