LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find application running as exe or dll?

Is there a way to find application is running as exe or dll?

 

any property or invoke node.

0 Kudos
Message 1 of 7
(3,460 Views)

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?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(3,447 Views)

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.

0 Kudos
Message 3 of 7
(3,435 Views)

Hi Naveen,

 

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(3,430 Views)

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?

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 7
(3,421 Views)

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.

Message 6 of 7
(3,414 Views)

@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).

 

 

Spoiler

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

DLL Or Exe.PNG

0 Kudos
Message 7 of 7
(3,308 Views)