04-21-2020 04:15 AM - edited 04-21-2020 04:22 AM
Hi All,
Does someone have experience with file extensions regkeys?
I have custom file extensions that I want to assign with my LabVIEW application. The LabVIEW side of things was easy, I just used the 'OS Open Document' event case. And by right-clicking a custom file I can ask windows to 'Open With...' and tick 'Do this for all <ext> files?'.
This works as expected - no issues (for my application I'm loading an SQLite database with a custom extension, but loading the file in LabVIEW is the same as the snippet I've shown)
However, I've been going around-in-circles trying to find a list of registry keys I need to set in my installer to make this happen when the end-user installs my software. A lot of the LabVIEW / LAVA forums reference expired links.
I've tried the following (but no success):
Looking in regedit the keys have updated as configured. I've tried restarting after installing the test application, but still " *.customfile " doesn't open with my application unless I assign it manually (right-click, open with...)
Whilst I'm on here, there are a few related things...:
Any guidance would be much appreciated.
Cheers,
Tom
Solved! Go to Solution.
04-21-2020 05:05 AM - edited 04-21-2020 05:06 AM
09-22-2020 08:59 AM
Hello Tom,
Have you found the solution to your problem? I'm trying to figure out the same as well.
Currently I have a batch (pyr.bat) and a registry script file (pyr.reg). The batch file is called by the installer at the end of the install process.
pyr.bat:
echo off
regedit /s pyr.reg
pyr.reg:
REGEDIT
HKEY_CLASSES_ROOT\.pyr = analytics
HKEY_CLASSES_ROOT\analytics = Analytics Data File
HKEY_CLASSES_ROOT\analytics\shell\open\command = c:\Program Files (x86)\AnalyticsPro\AnalyticsPro.exe "%1"
This works fine and it even links the icon of the executable to the .pyr files.
But I'm not happy with the c:\Program Files (x86)\ part of the pyr.reg file. I'm pretty sure this will not work correctly in other localised version of Windows.
09-22-2020 10:55 AM
Can you replace "c:\Program Files (x86)" with "%ProgramFiles(x86)%"?
https://stackoverflow.com/questions/19652678/how-to-mention-c-program-files-in-batchfile
09-23-2020 05:12 AM - edited 09-23-2020 05:32 AM
Hey Freel,
After not getting it working for a while I just moved on. However, I gave it another go after your comment.
Thanks for the batch file suggestion. I was trying to edit the registry items directly on the 'Register' page on the installer, but that didn't seem to work. However, getting a batch file to run after the installer worked great! Also, I didn't know about Registry Script Files, so thanks for showing me that too!
I've been able to get the custom extensions working great thanks to your help (icon, type, and default program changed). However, as you mentioned the "C:\Program Files" is hardcoded. I tried the suggestion of using %ProgramFiles% (64-bit program) but that wasn't successful, I also tried PROGRAMFILES64 - that didn't work either 😕
Update: I thought it would be helpful to attach a sample project
09-23-2020 05:50 AM
Hello Tom,
Maybe it is possible to replace the batch file with an VI that dynamically determines the program files folder, generates the registry script file and then runs it.
This VI should also be able to detect if the user has selected a different install location then the program files folder.
09-23-2020 08:19 PM - edited 09-23-2020 08:30 PM
I just had a look at how I've done this in the past (using the registry settings in the installer, not a batch file), and I had [INSTALLDIR] instead of "C:\Program Files\Application folder".
So in your example, it would be
"[INSTALLDIR]Application.exe" "%1"
instead of
"C:\Program Files\Open Custom Files\Application.exe" "%1".
Cheers,
Mark.
09-25-2020 06:26 AM
Great suggestions, thank you both - I will try those out later this week.
One issue I've run into (which I'm hoping you've come across), is that this dialog box pops up when I click on the file (with custom extension). Then when I click 'OK' the box closes and my application opens as expected (having correctly read the file).
Have you come across this before? How did you solve it?
This is the VI that runs at the start of my application to see if it was opened by a file:
09-25-2020 09:02 PM
Hi Tom,
I have modified your sample project to show how I usually do it.
The settings on the registry page of the installer are:
No, I don't get that dialog pop-up box that you mentioned.
By the way, thank you for your tip about the "OS Open Document" event - I had no idea that even existed.
The way I normally detected what document opened the application was by using the "Application" --> "Command Line Arguments" property:
But this relies on ticking the "Pass all command line arguments to application" checkbox when building the application.
I've just been playing around with this and it appears that when this box is ticked, the "OS Open Document" event no longer works.
Anyway, using the "OS Open Document" event seems a better way of doing it, as the application can detect when the user double-clicks on an associated file even when the application is already running.
I've attached the modified sample project (LV 2017 version).
09-25-2020 11:22 PM
@MIG wrote:
By the way, thank you for your tip about the "OS Open Document" event - I had no idea that even existed.
Neither did I. And I can't find anything in the help that explains how it works.