Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Version and/or location of OpenSSL DLLs in Delphi?

For troubleshooting purposes, is there a pragmatic way my app could check at runtime:

  1. whether the openssl dll's (ssleay32.dll and libeay32.dll) actually exist and will be able to successfully be loaded by my app?
  2. what path the openssl dll's are actually loaded from (so I could verify whether it's loading it from the copy in the app's directory, or whether it's picking up some stray copy from the system path somewhere)
  3. what version of openssl is my app (or Indy) using? (If I know the exact path, most versions of openssl dlls include the version info that I could check from viewing Windows file properties)
like image 456
Jessica Brown Avatar asked Jan 17 '26 18:01

Jessica Brown


2 Answers

Yes. In the same order you asked:

  1. Use LoadLibrary for each DLL and check the return value.
  2. If #1 succeeds, use GetModuleFileName to retrieve the full pathname to the DLL that was loaded..
  3. If #2 succeeds, use GetFileVersionInfo to see if the DLL has file version information available. If it does, use VerQueryValue to read the version info (the same info you see by viewing Windows file properties).

They're all available from the Windows unit. Examples of all three in Delphi should be found here at StackOverflow. If you can't find them, post separate questions (see below) here asking for help using them.

(Posts here should contain a single question, so that a single answer can be selected as an answer. If you include multiple questions in the same post, several people can each answer one of them separately; in that case, how do you choose which one to accept as correct?)

like image 127
Ken White Avatar answered Jan 20 '26 15:01

Ken White


Indy 10 has an IdOpenSSLSetLibPath() function in the IdSSLOpenSSLHeaders.pas unit so you can tell Indy where the DLLs are located, instead of it having to hunt for them on the OS search path.

The best option is to just ship the desired DLLs in your app's installation directory, then there is no guesswork needed to know what your app will load.

like image 41
Remy Lebeau Avatar answered Jan 20 '26 15:01

Remy Lebeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!