Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Directories and Dlls...

Posted on 1999-01-29
10
Medium Priority
?
150 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

618 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