View Full Version : Nedd Help ! Create file association - registry set problem ..
ruslanx
07-18-2009, 12:50 PM
I read FAQ - Create file association from > http://www.indigorose.com/forums/showthread.php?t=23670 and I try to make file association but I can do this ,syntax is wrong ... ( line from faq ) :
Registry.SetValue(HKEY_CLASSES_ROOT, "KQXEditor\\\\shell\\\\open\\\\command", "", SessionVar.Expand("%AppFolder%\\\\MyProgram.exe \\"%1\\"") , REG_SZ);
: Syntax Error
line=1: `)` expected near '%'
Is a wrong syntax in faq or Setup Factory bug ? , I tried to import from registry but then I click ok or check syntax it return the same error ...
what to do ???
sorry for my english ..
ruslanx
07-18-2009, 02:41 PM
I found a solution :D :
Registry.SetValue(HKEY_CLASSES_ROOT, ".jpeg", "", "jpegviewer", REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT, "jpegviewer\\\shell\\\\open\\\\command", "", SessionVar.Expand("%AppFolder%\\PhotoViewer.exe\\\"%1\""), REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT, "jpegviewer\\\\DefaultIcon", "", SessionVar.Expand("%AppFolder%\\jpeg.ico ,0\\"), REG_SZ);
this is working for me ... FAQ must corrected on this example ..
ruslanx
07-18-2009, 03:03 PM
I found a solution :D :
Registry.SetValue(HKEY_CLASSES_ROOT, ".jpeg", "", "jpegviewer", REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT, "jpegviewer\\\shell\\\\open\\\\command", "", SessionVar.Expand("%AppFolder%\\PhotoViewer.exe\\\"%1\""), REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT, "jpegviewer\\\\DefaultIcon", "", SessionVar.Expand("%AppFolder%\\jpeg.ico ,0\\"), REG_SZ);
this is working for me ... FAQ must corrected on this example ..
ruslanx
07-18-2009, 03:05 PM
warnig :) : > remove the space ... "%AppFolder%\\PhotoViewer.exe\\\*"%1\""), ... then you copy from web page
BigDeveloper
10-23-2009, 06:35 PM
My problem is thus.
I'm wanting to create an association with our unique files (Extention .ptv) with a specific program. The problem is that I first need to create a registry get value string that locates the folder that the program is located on the computer.
In the registry there is no listing of the folder path by itself. The value in the registry includes the executable in the paths
Example: C:\Program Files\FLV Player\FLVPlayer.exe
What code do I use to capture just the folder path without the filename.exe at the end.
Then how do I associating our .ptv files to this executable.
Also is the coding the same in Autoplay Media Studio
jassing
10-23-2009, 07:24 PM
Example: C:\Program Files\FLV Player\FLVPlayer.exe
What code do I use to capture just the folder path without the filename.exe at the end.
Have a look at String.SplitPath()
Then how do I associating our .ptv files to this executable.
Did you search the forums, I know I've posted this code before...
function File.SetAssocation(cExt, cExe, cIcon, cShort,cLong)
-- Set the file association for the given file.
Registry.CreateKey(HKEY_CLASSES_ROOT, cExt);
Registry.SetValue(HKEY_CLASSES_ROOT, cExt,"",cShort,REG_SZ);
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort);
Registry.SetValue(HKEY_CLASSES_ROOT, cShort,"","School Check IN Data File",REG_SZ);
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell");
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell\\open");
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell\\open\\command");
Registry.SetValue(HKEY_CLASSES_ROOT, cShort.."\\shell\\open\\command","",cExe.." %1",REG_SZ);
if not cIcon or not File.DoesExist( cIcon ) then
cIcon = cExe
end
Registry.SetValue(HKEY_CLASSES_ROOT, cShort.."\\DefaultIcon","",File.GetShortName(cIcon)..",0");
end
A call to it would be something like this:
File.SetAssocation(".PTV",SessionVar.Expand("%AppFolder%\\FLVPlayer.exe"), SessionVar.Expand("%AppFolder%\\FLVPlayer.ico"), "FLV Player File","FLV Player File/Movie");
Also is the coding the same in Autoplay Media Studio
Most code writen in one app will work fine in another. What you need to be sure of is that the object exists in the other platform. eg: SetupData. does not exist in anything except SUF.
BigDeveloper
10-26-2009, 11:36 AM
I don't know what I'm doing wrong on this. I'm a novice. The Key name in the Registry is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\App Paths\FLVPlayer.exe
and the code I have for spliting it and then running the program is:
RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\FLVPlayer.exe", "(Default)")
Split = String.SplitPath(RegVar);
NewRegVar = Split.Drive..Split.Folder;
File.Run(FLVPlayer.exe, "", NewRegVar, SW_MAXIMIZE, false);
It isn't working. it gives and error message that the FLVPlayer.exe is nil.
jassing
10-26-2009, 11:48 AM
did you create that entry?
do you test the results to be sure it contains a path?
This doesn't seem to be the same issue as before; but perhaps posting your project file & enumerating the problem clearly would be a good way to go.
BigDeveloper
10-26-2009, 12:09 PM
The key in the registry was created with the install of the FLVPlayer which is a Flash player. I'm trying to create a button in Autoplay studio that will look at the registry and find the location of the Flash player. and then run a flash video using that player.
Also, I was going to change the extension of our Flash Videos to be a unique extension and then associate that extension with this Flash player.
Right now I'm trying to tackle only one thing at a time and currenly I'm trying to simply program the button to run the flash player.
I have attached a zip file that includes the autoplay file and the registry file.
The More Perfect Union button is the one that has the code I'm working on. This is code that was given my by Adam Kapilik a long time ago. Maybe it's out of date.
Once I get this working I can begin on getting the file association to work.
BigDeveloper
10-26-2009, 12:10 PM
One more thing...
Maybe the File association ought to be set in the Setup factory install instead of the the Autoplay menu. Not sure if this matters.
BigDeveloper
10-26-2009, 12:19 PM
Also, here's some code I'm trying to use for checking.
RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\FLVPlayer.exe", "(Default)")
Split = String.SplitPath(RegVar);
if (Split ~= "") then
filename = Split .. "\\FLVPlayer.exe";
if File.DoesExist(filename) then
File.Run(filename, "", Split, SW_MAXIMIZE, false);
else
Dialog.Message("Error", "Could not find " .. filename, MB_OK, MB_ICONEXCLAMATION);
end
else
Dialog.Message("Error", "Could not locate expected value in the registry.", MB_OK, MB_ICONEXCLAMATION); end
BigDeveloper
10-26-2009, 12:30 PM
From trial and error, I just got it to work using the following code. I now need to modify line 7 to include the actual flash video that I want to play. This flash video will be located in the \\Autoplay\\Videos folder.
I would like the code to open this specific player and play the specific video.
I would also like to create an association between our unique extension and this player also
RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\FLVPlayer.exe", "")
Split = String.SplitPath(RegVar);
NewRegVar = Split.Drive..Split.Folder;
if (NewRegVar ~= "") then
filename = NewRegVar .. "\\FLVPlayer.exe";
if File.DoesExist(filename) then
File.Run(filename, "", NewRegVar, SW_MAXIMIZE, false);
else
Dialog.Message("Error", "Could not find " .. filename, MB_OK, MB_ICONEXCLAMATION);
end
else
Dialog.Message("Error", "Could not locate expected value in the registry.", MB_OK, MB_ICONEXCLAMATION); end
BigDeveloper
10-26-2009, 01:38 PM
So from your prior code you give on the file association, is there anything I would need to replace in there for my .ptv files or do I leave it like it is.
Also do place the first set of code in the Pre Install and the last in the Post install?
Pre Install code:
function File.SetAssocation(cExt, cExe, cIcon, cShort,cLong)
-- Set the file association for the given file.
Registry.CreateKey(HKEY_CLASSES_ROOT, cExt);
Registry.SetValue(HKEY_CLASSES_ROOT, cExt,"",cShort,REG_SZ);
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort);
Registry.SetValue(HKEY_CLASSES_ROOT, cShort,"","School Check IN Data File",REG_SZ);
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell");
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell\\open");
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell\\open\\command");
Registry.SetValue(HKEY_CLASSES_ROOT, cShort.."\\shell\\open\\command","",cExe.." %1",REG_SZ);
if not cIcon or not File.DoesExist( cIcon ) then
cIcon = cExe
end
Registry.SetValue(HKEY_CLASSES_ROOT, cShort.."\\DefaultIcon","",File.GetShortName(cIcon)..",0");
end
Post install Code:
File.SetAssocation(".PTV",SessionVar.Expand("%AppFolder%\\FLVPlayer.exe"), SessionVar.Expand("%AppFolder%\\FLVPlayer.ico"), "FLV Player File","FLV Player File/Movie");
jassing
10-26-2009, 01:42 PM
You would put the function delcaration in "global functions" or an external script file (that you then need to include in your project) and call it in post-install.
BigDeveloper
10-26-2009, 02:34 PM
I'm if I'm such a pain on this. but I think I'm close to the resolution.
I am using this in Setup Factory.
Since the installation of the FLVPlayer is separate from my Main install, I need to get the path to the FLVPlayer.exe from the registry. The following is what I have in the Post Install of my program along with your File.Association code.
RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\FLVPlayer.exe", "")
Split = String.SplitPath(RegVar);
NewRegVar = Split.Drive..Split.Folder;
File.SetAssocation(".PTV",SessionVar.Expand("%NewRegVar%\\FLVPlayer.exe"), SessionVar.Expand("%NewRegVar%\\FLVPlayer.exe"), "FLV Player File","FLV Player File/Movie");
This adds a key to the registry but when I then double click on one of my .PTV files it give me and 'Access Denied' error.
The Regestry.GetValue codes line and the following 2 line after worked in Autoplay but I'm not sure if it is correct for Setup Factory.
I have the following code in the global functions:
**********
function File.SetAssocation(cExt, cExe, cIcon, cShort,cLong)
-- Set the file association for the given file.
Registry.CreateKey(HKEY_CLASSES_ROOT, cExt);
Registry.SetValue(HKEY_CLASSES_ROOT, cExt,"",cShort,REG_SZ);
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort);
Registry.SetValue(HKEY_CLASSES_ROOT, cShort,"","School Check IN Data File",REG_SZ);
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell");
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell\\open");
Registry.CreateKey(HKEY_CLASSES_ROOT, cShort.."\\shell\\open\\command");
Registry.SetValue(HKEY_CLASSES_ROOT, cShort.."\\shell\\open\\command","",cExe.." %1",REG_SZ);
if not cIcon or not File.DoesExist( cIcon ) then
cIcon = cExe
end
Registry.SetValue(HKEY_CLASSES_ROOT, cShort.."\\DefaultIcon","",File.GetShortName(cIcon)..",0");
end
jassing
10-26-2009, 02:39 PM
You're the only one who can fix this...
what line generates the "access denied'?
does your other installer CREATE the registry entry you're looking for?
BigDeveloper
10-26-2009, 03:09 PM
OK, I now of the following lines in the Pre Install and Post Install respectively:
Pre Install:
RegVar = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\FLVPlayer.exe", "")
Split = String.SplitPath(RegVar);
NewRegVar = Split.Drive..Split.Folder;
Dialog.Message("Registry", "Your FLVPlayer is stored in:\n" .. NewRegVar, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Post Install:
File.SetAssocation(".PTV", NewRegVar.."\\FLVPlayer.exe", NewRegVar.."\\FLVPlayer.ico", "Flash.VideoFile","FLV Player File/Movie");
The Dialog.Message reports back the correct folder for the FLVPlayer.exe file. It creates the .PTV Key in Classes_Root.
When I click on one of my .ptv files it no longer gives an error message but brings up the 'Open With' window for me to choose a file to open it with.
I would like it to autmatically open it will the FLVPlayer.exe.
So I'm not sure if the File.Association is working.
How do I fix this?
Thanks
BigDeveloper
10-26-2009, 04:10 PM
Please look at my latest post. I think I'm close. I no longer get an error message but I get the 'Open With' window now.
Is there a way I can get phone support? I can explain this better over the phone.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.