PDA

View Full Version : code to open the program when click a file


lnd
04-29-2008, 07:43 AM
if i click *.doc the microsoft word open automatically.
i have a code who work good but i need the program to know the file path thet belonging to the file who opend the program.

i need an example thet insert the path file to a lable object or a variable.


function CreateFileAssociation(strApplicationPath, strFileExtension, strAppShortName, strIconFile)

Registry.SetValue(HKEY_CLASSES_ROOT, strFileExtension, "", 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

local strApplication = "d:\\LND.exe"
CreateFileAssociation(strApplication, ".rrr", "e:\\LND.exe", "e:\\1.ico",0) ;

RizlaUK
04-29-2008, 08:02 AM
the file path will be passed as the last argument in the _CommandlineArgs tabel

so to access the filepath sent to the exe, put this in page preload
if _CommandLineArgs[Table.Count(_CommandLineArgs)] then
strMyFilePath= _CommandLineArgs[Table.Count(_CommandLineArgs)]
end

lnd
04-29-2008, 09:49 AM
i get the program path and i need the file path.


example:
if i click "c:\text.doc" i get "c:\programfiles\office\word.exe" but i need to get "c:\text.doc"

RizlaUK
04-29-2008, 12:43 PM
in that case it would be the first item in the _CommandLineArgs tabel

if _CommandLineArgs[1] then
strMyFilePath= _CommandLineArgs[1]
end

lnd
05-01-2008, 12:27 PM
if i choose 2 files the program open 2 times and i need to open the program 1 time and get in variable 2 values. i need only to know how to open the program 1 time because i know how to get in variable 2 values.

RizlaUK
05-01-2008, 02:30 PM
huh....

do you mean, if your app is already running and you click a file ?

lnd
05-01-2008, 11:23 PM
if my app is already running and you click a file the file open a new app and i wont the file to go the old app.

lnd
05-05-2008, 02:02 AM
if i choice 2 or more files and click enter the program open more then 1 time and i need to open the program 1 time and get all the file list (more then 1 file)
in the _CommandLineArgs[1] ther is a string but in the _CommandLineArgs[2] i get an errore way??? (and i choice 2 files)

example
if i choice 10 mp3 files and click enter the microsoft media player open and you get in in the media player a list for all the files.