Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
894 views
in Technique[技术] by (71.8m points)

delphi - How to use a dll outside of the system path

I made an application that uses the openssl dlls (libeay32.dll and ssleay32.dll). It is indy using them, I don't call the dlls directly.

The simplest workaround i found to avoid an installer (i just delpoy an exe and i am ok with this approach) is to:

  1. put the dlls as resources of the exe
  2. on program start I extract them in the exe folder
  3. the exe uses them

This is perfect but I would like to improve the approach by extracting the dlls in a temp folder and not on the exe folder (that in many cases is the desktop).

The problem is that I don't know how to force the application to use the dlls in the temp folder, because now the behaviour is: if dlls are not in current directory try to search in the directories defined in the system path.

Who knows a solution to force indy to use the dlls in my temp path? (like "temporarly registering the dlls")

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you are using an up-to-date version of Indy 10, the IdSSLOpenSSLHeaders unit has a public IdOpenSSLSetLibPath() function to tell Indy which custom folder to look in for the OpenSSL DLLs:

procedure IdOpenSSLSetLibPath(const APath: String);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...