View Full Version : Custom extention for file
dorkauf89
01-20-2008, 11:10 PM
Can anyone convert this script from AMS7.0 script to AMS6.0? :
Registry.SetValue(HKEY_CLASSES_ROOT,".am6","","AMS60.Document",REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT,"AMS60.Document","","AutoPlay Media Studio 6.0 Document",REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT,"AMS60.Document\\DefaultIcon","","C:\\PROGRA~1\\AUTOPL~2\\ams60.exe,0",REG_SZ);
Registry.SetValue(HKEY_CLASSES_ROOT,"AMS60.Document\\shell\\open\\command","","C:\\PROGRA~1\\AUTOPL~2\\ams60.exe \\\"%1\\",REG_SZ);
I got this script from the following forum: http://www.indigorose.com/forums/showthread.php?t=17380
THANKS
dorkauf89
01-21-2008, 09:05 PM
Can anyone help me?
TimeSurfer
01-22-2008, 12:54 AM
read in that link you posted
quoted from dermot
Here is a function one the IR guys posted. I use it all the time and it works great.
Quote:
-----------------------------------------------------------
function CreateFileAssociation(strApplicationPath, strFileExtension, strAppShortName, strIconFile)
Registry.SetValue(HKEY_CLASSES_ROOT,strFileExtensi on,"",strAppShortName);
local strCommandLine = "\""..strApplicationPath.."\" \"%1\"";
Registry.SetValue(HKEY_CLASSES_ROOT, strAppShortName.."\\shell\\open\\command", "", strCommandLine);
if(File.DoesExist(strIconFile))then
local strApp83path = File.GetShortName(strIconFile);
Registry.SetValue(HKEY_CLASSES_ROOT, strAppShortName.."\\DefaultIcon", "", strApp83path..",0");
end3
end
-----------------------------------------------------------
-- Call like this
-- Replace "My App.exe" withe the name of your app
-- Replace "ext" with your extension
-- Replace "myappicon.ico" with the name of your icon
local strApplication = _SourceFolder.."\\My App.exe"
CreateFileAssociation(strApplication, ".ext", "My App", _SourceFolder.."\\AutoPlay\\Icons\\myappicon.ico") ;
dorkauf89
01-22-2008, 05:39 AM
that one too... I saw that one but it doesn't seem to work since it's for AMS7.0. Isn't the script kind of different? How do I make this script work in AMS6.0?
RizlaUK
01-22-2008, 06:39 AM
that script will work with AMS6,
remember you still need to tell the app what to do with the file once its path has been passed to the exe
example code only, may need slight edit
if _CommandLineArgs[Table.Count[_CommandLineArgs]] then
-- your code here
-- eg (this will add the file to a listbox with the filename as text and path as data
FilePath=_CommandLineArgs[Table.Count[_CommandLineArgs]]
ListBox.AddItem("ListBox", String.SplitPath(FilePath).Filename,FilePath)
end
Heres a example i made ages ago for this kind of thing
http://www.indigorose.com/forums/showthread.php?t=19358
dorkauf89
01-22-2008, 02:11 PM
when I tryed that second script everything worked except it didn't give the file an icon. The icon I told it to give... Your example works... Thanks
dorkauf89
03-10-2008, 05:19 PM
I came back to this post cause I needed to use this for another program i'm making. I see you still didn't answer why maybe it doesn't show the icon on the file. This is my script:
Global Functions:
-- set file assico
function CreateFileAssociation(strApplicationPath, strFileExtension, strAppShortName, strIconFile)
Registry.SetValue(HKEY_CLASSES_ROOT,strFileExtensi on,"",strAppShortName);
local strCommandLine = "\""..strApplicationPath.."\" \"%1\"";
Registry.SetValue(HKEY_CLASSES_ROOT, strAppShortName.."\\shell\\open\\command", "", strCommandLine);
if(File.DoesExist(strIconFile))then
local strApp83path = File.GetShortName(strIconFile);
Registry.SetValue(HKEY_CLASSES_ROOT, strAppShortName.."\\DefaultIcon", "", strApp83path..",0");
end
end
On Preload:
SetKey = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\DKNHpad", "Set Key", true);
if SetKey ~= "true" then
local strApplication = _SourceFolder.."\\autorun.exe";
CreateFileAssociation(strApplication, ".txt", "DKNHpad", _SourceFolder.."\\AutoPlay\\Icons\\file.ico");
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\DKNHpad", "Set Key", "true", REG_SZ);
end
On Show:
if _CommandLineArgs[1] then
if String.Left(_CommandLineArgs[1], 3) ~= "SFX" then
YourCustomFile = _CommandLineArgs[1]
defaultopentext = TextFile.ReadToString(YourCustomFile);
sPath = String.SplitPath(YourCustomFile);
Input.SetText("txt", defaultopentext);
FileLocation = YourCustomFile;
end
end
When I set my program as the default viewer for text files, it still keeps the old icon. I'm using windows vista if that helps in any way. I want it to give all text files the icon that is located at the autoplay/Icons/file.ico. Thanks!
dorkauf89
03-10-2008, 05:23 PM
Also, is it possible to set my program the default viewer for text files when they install it and they not having to set it as the default? And, I want my users to be able to just drag their file on my program instead of pressing the open button... find the fie... open it.... I want them to just drag it anywhere on the program and it will open it... HELP Thanks...
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.