-
June 2nd, 2005, 05:28 PM
#1
DLL problems
I created a program that uses a DLL that I also created. I put both program and DLL on a XP machine (not the one that I developed on) in the same directory. I also add a shortcut to the program on the desktop. I start the program by clicking on the shortcut and everything runs fine.
However, When I do this same thing (start the program by clicking the shortcut on desktop) on a Win 98 machine the program starts up okay but when the program enters where it calls on the DLL nothing happens. If the program is run by starting it from the directory where is is placed (and not from shortcut on desktop) the part where it calls upon the DLL runs fine and the DLL stuff works great.
What is it about starting the program from the shortcut on the Desktop makes it so the DLL will not run? And how can I get it to work? Thanks!
-
June 2nd, 2005, 05:40 PM
#2
Re: DLL problems
Originally Posted by senkyoshi
However, When I do this same thing (start the program by clicking the shortcut on desktop) on a Win 98 machine the program starts up okay but when the program enters where it calls on the DLL nothing happens. If the program is run by starting it from the directory where is is placed (and not from shortcut on desktop) the part where it calls upon the DLL runs fine and the DLL stuff works great.
That's strange - since on both systems the first place where DLLs are looked for is the directory from which the application is loaded. There are differences, though: See Dynamic-Link Library Search Order for details.
A thing to watch out for is how you are loading the DLL: Implicitly via an import library (but then your app would give you an error message when started) or explicitly via LoadLibrary()? If you are using LoadLibrary(), are you passing a full (absolute or relative) path, or just the DLL name? Other than that: Check the desktop shortcut's properties. Is there any path specified as the current directory for executing the target app?
-
June 2nd, 2005, 05:42 PM
#3
Re: DLL problems
Your executable make calls to the DLL and does the DLL do any intialization of any pathnames? Or what does the DLL actually do when it is called upon?
-
June 2nd, 2005, 05:50 PM
#4
Re: DLL problems
Originally Posted by kpy79
Your executable make calls to the DLL and does the DLL do any intialization of any pathnames? Or what does the DLL actually do when it is called upon?
Good point.
@senkyoshi: Under the light of kpy79's idea, you should probably check whether it's the LoadLibrary() call that fails, or if the DLL actually loads, but then fails do do some kind of path-dependent file operation. So if you are using LoadLibrary(): Did you check its return value?
-
June 2nd, 2005, 06:01 PM
#5
Re: DLL problems
Or, it could be a problem with the current directory for the app... You can try uing GetCurrentDirectory and see if there is a difference.
-
June 2nd, 2005, 06:04 PM
#6
Re: DLL problems
Thanks for the input everybody. Unfortunately the program that calls the DLL was not developed under Visual C++ but the DLL was developed under Visual C++.
I just found that if I place the DLL on the desktop with the shortcut it runs fine. So, it looks like when it runs it looks in the folder where the shortcut is at instead of in the target directory of the shortcut. Is this a Win 98 setting? Can I change this so the shortcut looks in the target directory instead of on the desktop? Thanks.
-
June 2nd, 2005, 06:07 PM
#7
Re: DLL problems
Originally Posted by senkyoshi
Can I change this so the shortcut looks in the target directory instead of on the desktop? Thanks.
Well, as said above: Have you checked the shortcut's properties? What's the current directory set to?
-
June 2nd, 2005, 06:08 PM
#8
Re: DLL problems
Right click on the desktop shortcut, select Properties.
In the shortcut tab, what are the entries for :
1. Target
2. Start in ?
-
June 2nd, 2005, 06:12 PM
#9
Re: DLL problems
Well, Target was correct but start in was blank. I didnt even see the Start in before. You learn something new everyday. I typed in the path for the dll and executable into "start in" and it works great now. thanks. So Start in means the place where it looks for files it depends on? Is this correct? that is what it looks like to me. Thanks again!
-
June 2nd, 2005, 06:19 PM
#10
Re: DLL problems
Originally Posted by senkyoshi
So Start in means the place where it looks for files it depends on? Is this correct?
No, it sets the current working directory (CWD) for the app. If you look at the link I posted, you'll see that (depending on the OS and the SafeDllSearchMode state) it's either the second or the fith place it searches when looking for dependent DLLs.
Last edited by gstercken; June 2nd, 2005 at 06:21 PM.
Reason: Typo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|