LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Registry Items for Custom File Extensions

Solved!
Go to solution

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?'.

 

OS Open DocumentOS Open Document

 

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

Registering the extensionRegistering the extension

 

Assigning an applicationAssigning an application

 

Assigning an icon (*.ico file)Assigning an icon (*.ico file)

 

 

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

  • Instead of restarting the PC, I've read there is a Windows app that can be called to 'refresh the file cache' (or similar) - any ideas of what that is?
  • Where can I set the 'file type' (as seen in windows explorer)
  • I haven't been able to change the file icon at all, do you know what the syntax should be?

 

Any guidance would be much appreciated.

 

Cheers,

Tom

0 Kudos
Message 1 of 12
(3,370 Views)

HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts

 

(You might also look up that information in MSDN. Or find those keys by searching for a specific file extension in RegEdit…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 12
(3,346 Views)
Solution
Accepted by topic author McQuillan

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.

Message 3 of 12
(3,117 Views)

Can you replace "c:\Program Files (x86)" with "%ProgramFiles(x86)%"?

 

https://stackoverflow.com/questions/19652678/how-to-mention-c-program-files-in-batchfile

Message 4 of 12
(3,102 Views)

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

0 Kudos
Message 5 of 12
(3,073 Views)

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. 

0 Kudos
Message 6 of 12
(3,066 Views)

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.

Message 7 of 12
(3,037 Views)

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?

McQuillan_0-1601032989097.png

 

This is the VI that runs at the start of my application to see if it was opened by a file: 

McQuillan_1-1601033179770.png

 

 

0 Kudos
Message 8 of 12
(3,005 Views)
Solution
Accepted by topic author McQuillan

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:

 

MIG_0-1601084112805.png

 

MIG_1-1601084245707.png

 

MIG_2-1601084341204.png

 

MIG_3-1601084405413.png

 

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:

MIG_4-1601084932464.png

But this relies on ticking the "Pass all command line arguments to application" checkbox when building the application.

MIG_5-1601085078139.png

 

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

 

0 Kudos
Message 9 of 12
(2,990 Views)

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

0 Kudos
Message 10 of 12
(2,984 Views)