TomB
TomB

Reputation: 760

How to detect that Delpi code is running in a DLL?

I am creating a [Windows] DLL which is primarily for use by non-delphi callers. I want to use some existing "library" code but there are some parts that might be inappropriate or problematic if they are being executed within a DLL.

Is there a way of detecting that the code is running within a DLL?

Upvotes: 2

Views: 486

Answers (2)

USauter
USauter

Reputation: 335

if MainInstance <> HInstance then // => DLL

IsLibrary always has the value FALSE if runtime packages rtl are used consistently. The IsLibrary and IsConsole variables are global in this case. The values ​​are set by the exe. They are not changed by the DLL.

Upvotes: 1

Remy Lebeau
Remy Lebeau

Reputation: 596477

System.IsLibrary

Indicates whether the module is a shared library.

The IsLibrary variable is True if the module is a dynamic link library (DLL).

Upvotes: 8

Related Questions