LabVIEW Development Best Practices Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How to open another file in a LabVIEW exe by double click?

I know how to double click to open a file using an exe built by LabVIEW.

1. Write code to read Application argument(command line).Then build the exe.

2. link my exe to the file extention.

3. Then double click the file we can open the file in the LabVIEW exe.

But here is my question. When this LabVIEW exe is running how to open another file in this exe by double clicking?

I've tried to read the latest. The Application argument property only read out the command line the first time this exe launched.

0 Kudos
Message 1 of 5
(6,003 Views)

That's because LabVIEW registers itself also as DDE receiver and Windows will first attempt to pass the Open file request by DDE to it, before deciding to launch a new executable and pass it the paramaters on the command line. While it is common practice to spawn a new process under Unix, everytime you need to open a file with that application this is not how Windows standard behaviour works. The reason is probably twofold. For one there didn't exist a commonly accepted standard way of communicating between application like DDE was. Yes you had pipes and they work great but each application uses it's own wire protocol so there is no way to have a shell pass standard commands to all applications over it. Also process creation on Windows is supposedly a lot more expensive so the DDE approach made sense and was there from old Win 16 Bit days already and the shell interaction was made standard by the old File Manager back then.

So how could you go about your problem?

Well since you know that LabVIEW receives an Open Document DDE command you can try to use the according event in the event structure and see if it works. It wasn't exposed in earlier versions but should be now. It did have a limitation to only work for well known LabVIEW file types, but that may have changed too in the meantime.

If this fails, your only chance is to create a seperate launcher executable. Install this in the registry as file launcher for your file type. This launcher executable then connects to your real LabVIEW application through VI Server and passes it the file name. Then it terminates itself so that Windows can launch it again for the next file request. Just don't register any DDE assocation in the registry for your launcher or it may fail to launch subsequent file open requests if they are to quick after each other (especially selecting more than one file at the same time and trying to load them in your app).

Rolf Kalbermatter
My Blog
Message 2 of 5
(4,121 Views)

Rolf nailed it. I've done the separate launcher EXE before in a distributed application, and it works fine. The only downside is that there's a noticeable delay while the LVRTE spins up, and a taskbar window appears for the launcher for ~1 sec while it does its work. You might make the launcher into a splash screen for your application to justify its existence on the taskbar and the time it takes to launch the real app.

Message 3 of 5
(4,121 Views)

Thanks, Rolfk,

I get it. I've thought about the idea of a seperate launcher but not the VI server.

I'will give it a try~!

0 Kudos
Message 4 of 5
(4,121 Views)

Yes!

The OS open document works fine.

Thanks David and Rolfk!

0 Kudos
Message 5 of 5
(4,121 Views)