?
Solved

Directories and Dlls...

Posted on 1999-01-29
10
Medium Priority
?
148 Views
Last Modified: 2010-04-06
I have an application which has A.EXE and B.DLL in C:\MyApp\ directory. In subdirectory C:\MyApp\Sub1\ I have C.DLL and D.DLL. When A.EXE is executed, it is loaded with B.DLL as well because A.EXE is statically linked with B.DLL.

When user click a button in A.EXE, A.EXE will dynamically call C.DLL in C:\MyApp\Sub1\. C.DLL will change the current directory to C:\MyApp\Sub2\, a new directory, using ChDir(), after that, C.DLL will dynamically call D.DLL. D.DLL is statically linked with B.DLL as well which is located in C:\MyApp\.

D.DLL cannot be loaded and gives me an error saying 'A required .DLL file, B.DLL, was not found.'.

A.EXE uses CreateProcess() to call C.DLL and B.DLL is already in the memory, why can't D.DLL be loaded? Any solution to this?

I've tried this, before C.DLL calls D.DLL, it changes the directory back to C:\MyApp\, then D.DLL can be loaded.

But what I don't understand is that, how do I make D.DLL understand that B.DLL has already in the memory?

Phew...a long one...
0
Comment
Question by:foxvision
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1363780
First of all: Why do you use CreateProcess('d.dll') instead of LoadLibrary('d.dll')?

However, if you use something like this:
CreateProcess(extractFilePath(ParamStr(0))+'Sub1\c.dll');
or LoadLibrary(extractFilePath(ParamStr(0))+'Sub1\c.dll');
and the same for d.dll, everything should by fine.

Regards, Madshi.
0
 

Author Comment

by:foxvision
ID: 1363781
Sorry, Madshi.

I temporarily reject your answer as I've made a mistake. C.DLL is C.EXE and C.EXE is loading D.DLL using LoadLibrary.

Are the answer is still the same?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1363782
I think so. Please just try it and tell me if it works. But I'm quite sure about that...

Regards, Madshi.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:Wrath
ID: 1363783
Maybe im not understanding fully , but you can just put all your Dll's in the Windows/System directory, and access them from there...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1363784
I hate it when all programs put their dlls into the system directory. That makes sense only when a lot of applications are using the same dll, though in such a situation there are often version problems. And if the dlls are only used by one program, it doesn't make much sense to put them into the system directory. The user who looks in the system directory sees 10.000 dlls and does not know which dll belongs to which program. It's terrible. So IMHO it is much much better to put your private dlls in your private directory!

Regards, Madshi.
0
 

Author Comment

by:foxvision
ID: 1363785
Yes, Wrath, I agree what Madshi said. We have tried putting them in the SYSTEM directory in the first time and they work for us. The fact is, we don't want this, as this application is installed onto the server and we don't want only 1 or 2 files to be put into the workstations only to have a problem of updating thses files later.

Madshi, please give me a few days more to try out your solution. Thanks.
0
 

Expert Comment

by:Wrath
ID: 1363786
Well thats fine.. no problem,, The question was waiting on an answer and I answered the question, with an answer that worked, For some people using the systems directory is not a problem, I did not see anywhere in your question stating you did not want to use the system directory.. I apologize, im thought I was helping , dont take this as an attack, just stating my case for this situation :)
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1363787
Hi Wrath, you don't need to apologize. Your suggestion works, though IMHO it's not the best one...    :-)

Regards, Madshi.
0
 

Author Comment

by:foxvision
ID: 1363788
Madshi, I didn't want the path to be hard coded, is it possible? If not possible, please repost your previous answer so that I can give you the point.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 540 total points
ID: 1363789
I'm not sure what do you mean with hard coded?
Ok, the dlls have to be in hard coded directories but relative to your application's path.
So you could move your application from "c:\myApp" to "c:\programs\blabla" without any problems! Only the dlls have to be in the same RELATIVE subdirectory.
If you don't like that, you could search for the dlls and then give the found path into LoadLibrary. However, if the dlls neither are in the windows(\system) nor in your application's directory, you MUST tell windows the path. Otherwise windows won't find them...

Regards, Madshi.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question