searching for dll in runtime.

Hello
One of our windows C application a.exe is developed in VS .NET 2003 IDE.
In runtime this app a.exe is searching for xyz.dll in
c:\abc folder first
and
C:\def fodler next

I want to make my application a.exe first search in C:\def first.
What should i do for this?
Sham
mohet01Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

raysonleeCommented:
It is not safe to use same DLL name and put different versions in different directories. The system's PATH will determine the search order and there are other factors affect the search order of DLL. e.g. If the DLL is already loaded in memory, it'll not be searched and loaded again even it's in another directory.

Refer to http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx for more details.
0
mohet01Author Commented:
Hello Rayson
Can't we say abc.exe to search for xyz.dll in particular path using some linker option in Projetc->Properties?
Sham
0
raysonleeCommented:
As stated in the above link, you can set it in your program with SetDllDirectory, refer to http://msdn.microsoft.com/en-us/library/ms686203%28VS.85%29.aspx as well.
However there are changes that the system won't search it at all.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

mohet01Author Commented:
There is no scope of modifying the code
0
raysonleeCommented:
Another method is to store the path in registry: http://www.codeguru.com/Cpp/W-P/dll/article.php/c99
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mohet01Author Commented:
perfect
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.