Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Register file type to launch VFP app

Status
Not open for further replies.

jjtaylor

Programmer
Joined
Dec 11, 2002
Messages
8
Location
US
Is there a way to register a file extension so that when I try to open it through Explorer it will launch my VFP6 application. I was wanting to compress archive data and give it an 'odd' extension. My VFP once launched uncompresses the file and runs the decryption. What I want is to allow users to select the file through Explorer and automatically launch the app instead of launching the VFP app and then selecting the file.
 
JJ,

If you have access to the user's computer, open a folder window, select View / Folder Options / File Types. Then click on New Type, and enter details of the file type which you want to register. The important things to enter are associated extension and the actions.

If you don't have access to the user's system, you can do it by programmatically storing some values in the registry, but off-hand I can't tell you what those values are. I hope someone else can.

Mike


Mike Lewis
Edinburgh, Scotland
 
Yes, I was wanting to do this programmatically. The potential number of installations is large. I know it will require some type of registry entry.
 
JJ,

I'm not an expert on this, but as far as I can see, you will need to put two entries in HKEY_CLASSES_ROOT.

The first entry is for the extension itself. This will contain a [Default] setting containing the name of the application.

Then you wil need an entry for the application. This contains a reference to the default icon, plus the information needed to act on the file through the Windows shell.

One way of simplifying the programming might be to create the entries interactively on your own computer (using Folder Options), then to export them to a REG file. You distribute this file to the users, then programmatically execute it using, say, ShellExecute().

If you get it working, let us know so others can use the tecnnique.

Mike


Mike Lewis
Edinburgh, Scotland
 
jjtaylor

To compliment what Mike Lewis said, if you go a sample table you have and rename it myTable.aaa and double click on it, typically a window asking you what program to use to open this file.
Now if you use the REGEDIT and go to HKEY_CLASS_ROOT and check first what the key say under .DBF and create a new Key (.aaa) and in the default value of the key put the same information as the .dbf key, and that should allow you to open your renamed table.

Mike said "Then you wil need an entry for the application.", I have not gone that far since in this case it did not seem to need it and the .dbf Key only contained one entry (In my case "Visual.FoxPro.Table.5" since VFP5 was lasr version of VFP installed on my system).

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks, Mike G. and Mike L.

I will see what I can do and let you know.

JJT
 
Mike,

Mike said "Then you wil need an entry for the application.", I have not gone that far since in this case it did not seem to need it

I think the entry for the application is to let you perform operations on the object from within the Windows shell. For example, right-clicking on it and selecting things like Print or Edit.

Mike


Mike Lewis
Edinburgh, Scotland
 
Mike

I think the entry for the application is to let you perform operations on the object from within the Windows shell. For example, right-clicking on it and selecting things like Print or Edit.

Makes sense, I just wasn't sure if it was required, or even since this seems to be a security issue, if it wasn't best to actually not create that second key, and prevent any actions other the opening the table withing the application.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

, I just wasn't sure if it was required, or even since this seems to be a security issue

I think I've reached the limit of my knowledge on that one. This is where I usually resort to trial-and-error.

Mike


Mike Lewis
Edinburgh, Scotland
 
Is this what you are looking for?

DO associatefile WITH ".aaa", "MyProgramFile", "C:\Program Files\MyFolder\MyExecutable.exe"

PROCEDURE associatefile (sExtension, sFileDescription, sExecutable)
LOCAL sErrorHandler
sErrorHandler = ON("error")
ON ERROR &&Necessary since the regdelete lines will error out if it doesn't exist
oShell = CreateObject("wscript.shell")
oShell.Regwrite ("HKCR\" + sExtension + "\", sFileDescription)
oShell.Regwrite ("HKCR\" + sFileDescription + "\", "MY PROJECT")
oShell.Regwrite ("HKCR\" + sFileDescription + "\DefaultIcon\", sExecutable)
oShell.Regwrite ("HKCR\" + sFileDescription + "\shell\open\command\", sExecutable + " %1")
oShell.Regdelete ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\Application")
oShell.Regwrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\Application", sExecutable)
oShell.Regdelete ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\OpenWithList\")
oShell.Regwrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" + sExtension + "\OpenWithList\a", sExecutable)
ON ERROR &sErrorHandler
ENDPROC


Slighthaze = NULL
 
Thanks everyone for all the help and comments.

The code supplied by Slighthaze worked great.

JJTaylor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top