Slighthaze = [color blue]NULL[/color]
Want MyExecutable.exe to automatically start when the user clicks on a file with .AAA as the extension? It's the same thing that happens when all those graphics programs on your PC are fighting over which gets to open the .JPG extension files when you double-click on a JPG image file. With the code below your new VFP Graphics application will be ready to fight over those JPG files too. ([color red]IMPORTANT:[/color] Caution while playing with this code, you can end up with all kinds of invalid associations on your PC - such as a non-existant MyExecutable.exe program being associated with files that have .aaa extensions)
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.