LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

List directory inside exe?

Solved!
Go to solution

Is it possible to list a directory inside an exe? I'm trying to dynamically load some VI's. I would like to just include a /plugins folder inside my executable build, then search the contents of that folder and present a list to the user. "List Folder" returns Error 7.

 

I know I'm giving it the right folder because (for testing) I have the plugins folder included in Startup VI's, and right now all it does is call Current VI's Path and display it. My test VI also shows the search paths. It all works in the dev environment, but in the build I get error 7. My paths are:

 

LookForVIs path:
C:\dev\builds\MyProject\Executable.exe\source\Main\LookForVIs.vi

 

Search path within LookForVIs, provided to List Folder:
C:\dev\builds\MyProject\Executable.exe\plugins

 

The \plugins folder contains myVI.vi, which just returns Current VI's Path as:

C:\dev\builds\MyProject\Executable.exe\plugins\myVI.vi

 

So all the files are indeed there inside the executable, but List Folder can't see any of them. Can I get a list of these files somehow?

 

 

Aside: I am trying a plugin architecture. I realize this requires a rebuild every time I change a plugin, but I don't want to distribute source code and after spending over a week trying to move to PPL's, I had to just move on for now. The code uses the Actor Framework with a giant pile of inheritance. Modifying this project to use PPL's as templates etc after this long in development just wouldn't work; I couldn't get the linking to work right. It wouldn't be bad starting from scratch, but right now I'm fine with using "built in" plugins inside the exe, as long as that actually works.

 

0 Kudos
Message 1 of 6
(1,258 Views)

While I don't know how to solve your actual problem with listing the EXE contents, maybe there's another option here.

 

If you're using actor framework with a bunch of inheritance, then what you're actually looking for is a list of all classes loaded in memory that descend from certain other classes, right?

 

If that's the case, then I would point you to a thread that I posted a few years ago that was recently updated:

https://forums.ni.com/t5/LabVIEW/Performance-of-LVclass-quot-Children-in-memory-quot-node/m-p/420003...

 

In this thread I was annoyed at the performance of something, but the idea and eventual solution probably could apply to you.  Basically, use the "Application.All Libraries in Application Instance" property node to list all libraries, see which of those are classes that can be cast to your desired class descendant (Actor, Message, whatever), then get the list of those and iterate through them as you like.

Message 2 of 6
(1,232 Views)

Wow, thanks Kyle. That looks like it may be a good workaround. I assume that will return all libraries built into the application, even if they're not in memory yet?

 

As an aside to the original question: I just tried adding "Check if file or folder exists" and manually defining the name within my application to myVI.vi. It returns False, even though the VI is in fact built, because it's running and I can see its front panel! The search path for Check if File or Folder Exists is identical to the Current VI's Path returned on the front panel of myVI.vi. Somehow, it thinks it doesn't exist.

 

I may end up just using Kyle's version as I am indeed using classes (actors, specifically) but I'd like to understand why my original question doesn't work, as Kyle's method doesn't work for non-OOP items. (I don't have any dynamically loaded non-OOP items right now, but it seems like the method should work so I'd like to understand where my knowledge is lacking).

 

Edit: OK, I'm confused about something. I tried running the App.AllVIs property node and it returned an empty array in the built executable. For clarity I'm doing all of this in my Launcher.vi that I'm using to launch my Actor Framework code, so sure some stuff may not be in memory yet... but literally nothing? I'm clearly confused on how all of this works in a built exe.

 

Edit 2: I tried AllLibsInAppInstance and got a big list of classes... but not the fake demo class I put in the \plugins folder. Looks like nothing loaded it into memory, which I suppose makes sense. How do I load up these VI's in memory if I don't know their names?

0 Kudos
Message 3 of 6
(1,221 Views)

@BertMcMahan wrote:

 

 

Edit 2: I tried AllLibsInAppInstance and got a big list of classes... but not the fake demo class I put in the \plugins folder. Looks like nothing loaded it into memory, which I suppose makes sense. How do I load up these VI's in memory if I don't know their names?


I find that if I drop a class constant for it on any VI included in the build it shows up with the AllLibsInAppInstance property.

0 Kudos
Message 4 of 6
(1,208 Views)

Yeah, constants are what I'm using now, I'm trying to just do "all classes in this folder" to decouple things.  I've heard one trick is to use a pre-build VI to get all of the class names and either script a blank VI with all the constants, or just cache their names into a VI somewhere.

0 Kudos
Message 5 of 6
(1,203 Views)
Solution
Accepted by topic author BertMcMahan

OK, based on this thread:

 

https://forums.ni.com/t5/LabVIEW/Getting-vi-directory-list-from-LabVIEW-executable-internally/td-p/3...

 

the answer is just "you can't do it". So there will need to be some pre-build VI that generates a list of classes that I can load. I don't love this but it's not a showstopper.

 

I'll leave the thread open for a bit longer, otherwise I'll mark this as a solution. Apparently, you just can't list directories inside an executable anymore.

0 Kudos
Message 6 of 6
(1,193 Views)