searching for dll in runtime.

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
C:\def fodler next

I want to make my application a.exe first search in C:\def first.
What should i do for this?
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.

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 for more details.
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?
As stated in the above link, you can set it in your program with SetDllDirectory, refer to as well.
However there are changes that the system won't search it at all.
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
Another method is to store the path in registry:

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:
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

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.