[ Smilebey @ 12.02.2005. 02:36 ] @
Kako dodavati nastavke(extension) i odgovarajuce aplikacije, kojem se otvaraju te ekstenzije, u listu File Types? Ako moguce: mijenjati ikonicu, editovati postojece nastavke...) |
[ Smilebey @ 12.02.2005. 02:36 ] @
[ bancika @ 12.02.2005. 11:12 ] @
evo resenjaaaaa :)
ovo je clanak koji sam koristio (nije moj doduse): kad se pokrene neki fajl sa tom extenzijom pokrenuce se tvoj program i dobices ime pokrenutog fajla kao parametar. zato na OnCreate stavi: if ParamCount > 0 then uradi nesto sa ParamStr(1), to je ime fajla Code: For creating file associations you should make some registry changes and inform Windows explorer about your changes. For launching your programm as default for all unregistered file types just associate it for "*" file type. The following unit includes realization of function for creating file association. See comments in source for details. unit utils; interface uses Registry, ShlObj, SysUtils, Windows; procedure RegisterFileType(cMyExt, cMyFileType, cMyDescription, ExeName: string; IcoIndex: integer; DoUpdate: boolean = false); implementation procedure RegisterFileType(cMyExt, cMyFileType, cMyDescription, ExeName: string; IcoIndex: integer; DoUpdate: boolean = false); var Reg: TRegistry; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CLASSES_ROOT; Reg.OpenKey(cMyExt, True); // Write my file type to it. // This adds HKEY_CLASSES_ROOT\.abc\(Default) = 'Project1.FileType' Reg.WriteString('', cMyFileType); Reg.CloseKey; // Now create an association for that file type Reg.OpenKey(cMyFileType, True); // This adds HKEY_CLASSES_ROOT\Project1.FileType\(Default) // = 'Project1 File' // This is what you see in the file type description for // the a file's properties. Reg.WriteString('', cMyDescription); Reg.CloseKey; // Now write the default icon for my file type // This adds HKEY_CLASSES_ROOT\Project1.FileType\DefaultIcon // \(Default) = 'Application Dir\Project1.exe,0' Reg.OpenKey(cMyFileType + '\DefaultIcon', True); Reg.WriteString('', ExeName + ',' + IntToStr(IcoIndex)); Reg.CloseKey; // Now write the open action in explorer Reg.OpenKey(cMyFileType + '\Shell\Open', True); Reg.WriteString('', '&Open'); Reg.CloseKey; // Write what application to open it with // This adds HKEY_CLASSES_ROOT\Project1.FileType\Shell\Open\Command // (Default) = '"Application Dir\Project1.exe" "%1"' // Your application must scan the command line parameters // to see what file was passed to it. Reg.OpenKey(cMyFileType + '\Shell\Open\Command', True); Reg.WriteString('', '"' + ExeName + '" "%1"'); Reg.CloseKey; // Finally, we want the Windows Explorer to realize we added // our file type by using the SHChangeNotify API. if DoUpdate then SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil); finally Reg.Free; end; end; end. [ Smilebey @ 12.02.2005. 14:14 ] @
Hvala Bancika!!!
[ Nemanja Avramović @ 12.02.2005. 15:25 ] @
...a kako spreciti da se pokrene moja aplikacija ukoliko je jedna instanca vec pokrenuta? kao npr. dvoklik na mp3 a on ga pusti u vec otvorenom winamp-u...?
[ reiser @ 12.02.2005. 15:32 ] @
Preko mutex-a :
Code: If WaitForSingleObject(CreateMutex(nil, FALSE, 'Jedinstveno_Ime_Mutexa', 0) = wait_TimeOut Then Close; Ovaj kod proverava da li postoji gore navedeni mutex. Ako postoji, zatvara formu. [ bancika @ 12.02.2005. 23:32 ] @
to nije bas tako jednostavno...treba proslediti parametar prvoj instanci..npr kad kliknes na mp3 fajl a winamp je pokrenut ova nova instanca prosledi ime fajla staroj pa se tek onda zatvori...
[ reiser @ 13.02.2005. 16:09 ] @
Onda ne vidim drugo resenje osim koriscenja nekog vida IPC...
Jedan slican problem sam resio preko pipe-a. Imas primer u attachment-u. Startuj jednu instancu programa, i zatim drugu pozovi sa nekim parametrom. Prva instanca ce prikazati messagebox cija je sadrzina parametar sa kojim si pozvao drugu instancu. [ Peke @ 14.02.2005. 01:51 ] @
Je li probao neko preko direktnog spajanja na Thread i onda preko Thandle doci do parametara? Radio sam nesto slicno pre koju godinu ali izgubio sam gomilu src-a kada mi je zveknuo HDD. Mislim da moze preko DDE da se odradi.
Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|