04-09-2020 01:46 AM
Is there a way to find application is running as exe or dll?
any property or invoke node.
04-09-2020 02:00 AM
Hi naveen,
@naveen_k wrote:
Is there a way to find application is running as exe or dll?
any property or invoke node.
There is the App.Kind property you can read…
(How does an application run as DLL?)
04-09-2020 02:14 AM
Actually i have set of functions.
that can be called using UI (Exe standalone).
and i converted same code to dll to reuse those functions in other application.
I need to disable some functions like dialog box, if it is dll.
App.Kind won't return dll or not.
04-09-2020 02:22 AM
04-09-2020 02:29 AM - edited 04-09-2020 02:40 AM
How "safe" has this to be?
You could also turn this around and add a global to the VI hierarchy. Default it is false. From your exe, set this global to true at the start of your program. Inside the DLL just leave it as it is (and don't export any function to set this global).
Usually the simple solutions are the best, unless there is a very compelling reason not to use it! No need to try to detect something inside LabVIEW or Windows that could suddenly change with the next version. If you can build it yourself in your app easily then do it!
Uli's solution with Conditional Compile structure is also a good one. Why even include the code in the DLL that is never supposed to run?
04-09-2020 02:37 AM
I would go with 'Conditional Disable Symbols' in the project properties and use a 'Conditional Disable Structure' in the code. Change the 'Conditional Disable Symbol' in the project properties before creating an executable or a dll.
04-10-2020 07:33 AM
@GerdW wrote:
what happens when you try to read the path to the VI, like CurrentVIsPath or AppDirectory?
Can you distinguish between your own executable and the functions in a DLL using their path?
Current VI Path (stripping the VI name):
VI in LV: LabVIEW.exe - E:\
VI in dll in LV: LabVIEW.exe - E:\SharedLib.dll
VI in EXE: Application.exe - E:\Application.exe
VI in dll in EXE: Application.exe - E:\SharedLib.dll
Application name:
VI in LV: LabVIEW.exe
VI in dll in LV: LabVIEW.exe
VI in EXE: Application.exe
VI in dll in EXE: Application.exe
Combined this should be enough to distinguish the 4 situations (VI\LV, DLL\LV, VI\EXE, DLL\EXE).
Be careful, your dll\exe doesn't have to have proper extensions... If you name your dll .exe for instance...
VI's in libraries\classes could complilate things as well. Haven't tested that.
Result (code, from LabVIEW, from exe):