RE: Help w/Registered File Types
Again, thanx to all who replied, I wanted to stay away from querying the registry continuously as it not only noticeably slows down this operation but the more times I run it the slower it seems to get! Anyone else seen this with the registry? Anyway, I'm updating an app I wrote some time back for a guy and wanted to automate this part of it. It basically provides file launching and in the original version the user made a choice at the time a file is added to the launcher if it should be made to run as a filename or a parameter. If the latter, the user could then decide to run it using its registered application or a named secondary application. If it was a data file this works great but if an exe or some other stand-alone type it was confusing. The various methods for checking if it had a registered application and if so what its path and name is was too slow, so I considered building my own list when a file is used the first time. That was much faster, but the user still was faced with making a decision for each file. So finally I decided to store a string of delimited stand-alone file-extensions and check against it when the file is being used. If not one of these types it gets used as a parameter, otherwise it goes in as a filename. This is a much shorter list and a lot faster, plus new types can be added to the list by the user anytime wanted. from Robert Meek dba Tangentals Design e-mail: [EMAIL PROTECTED] Freelance Windows Programming for XP and Vista Also proud to be a Moderator of the Delphi-List at elists.org Reality cannot be explained...only enjoyed or endured as your current perspective allows! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of CubicDesign Sent: Monday, May 19, 2008 11:24 AM To: Borland's Delphi Discussion List Subject: Re: Help w/Registered File Types Oh... I forgot. The registry path where this association is keep, is HKey_classes_root. Robert Meek wrote: Morning all, I have an urgent need that I hope someone here can help me figure out how to handle, involving how to find out the full path and filename of an application via it being the registered file type for a selected data file! In my application, the user selects a data file, for example a .doc file which on most systems will be registered to open with Microsoft Word. How can my application find out if it has a registered application, what its registered application is, and return the path and filename of it to the user without actually launching the data file? Thanx in advance for any help! from Robert Meek dba Tangentals Design e-mail: [EMAIL PROTECTED] Freelance Windows Programming for XP and Vista Also proud to be a Moderator of the Delphi-List at elists.org Reality cannot be explained...only enjoyed or endured as your current perspective allows! ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
Re: Help w/Registered File Types
Look in registry for that extension to see which application in associated with it. This is a 2 step process. Manually search your registry for .jpg and see an application associated with the jpg files. Then look for that application and you will find its path. If you cannot find that extension in registry or the key associated is an empty string, then no application is associated with it. Robert Meek wrote: Morning all, I have an urgent need that I hope someone here can help me figure out how to handle, involving how to find out the full path and filename of an application via it being the registered file type for a selected data file! In my application, the user selects a data file, for example a .doc file which on most systems will be registered to open with Microsoft Word. How can my application find out if it has a registered application, what its registered application is, and return the path and filename of it to the user without actually launching the data file? Thanx in advance for any help! from Robert Meek dba Tangentals Design e-mail: [EMAIL PROTECTED] Freelance Windows Programming for XP and Vista Also proud to be a Moderator of the Delphi-List at elists.org Reality cannot be explained...only enjoyed or endured as your current perspective allows! ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
Re: Help w/Registered File Types
Oh... I forgot. The registry path where this association is keep, is HKey_classes_root. Robert Meek wrote: Morning all, I have an urgent need that I hope someone here can help me figure out how to handle, involving how to find out the full path and filename of an application via it being the registered file type for a selected data file! In my application, the user selects a data file, for example a .doc file which on most systems will be registered to open with Microsoft Word. How can my application find out if it has a registered application, what its registered application is, and return the path and filename of it to the user without actually launching the data file? Thanx in advance for any help! from Robert Meek dba Tangentals Design e-mail: [EMAIL PROTECTED] Freelance Windows Programming for XP and Vista Also proud to be a Moderator of the Delphi-List at elists.org Reality cannot be explained...only enjoyed or endured as your current perspective allows! ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
Re: Help w/Registered File Types
Hi Robert Some old code gleaned sometime ago from the net - hope it helps function FindAssociatedApp (const Ext : string) : string; // adapted by HAB from community.borland.com Question and Answer Database // Article #15801: Retrieving the program that is associated with a given extension // 16-bit sections removed var reg: TRegistry; s : string; begin s := ''; reg := TRegistry.Create; reg.RootKey := HKEY_CLASSES_ROOT; if reg.OpenKey('.' + ext + '\shell\open\command', false) false then begin {The open command has been found} s := reg.ReadString(''); reg.CloseKey; end else begin {perhaps there is a system file pointer} if reg.OpenKey('.' + ext, false) false then begin s := reg.ReadString(''); reg.CloseKey; if s '' then begin {A system file pointer was found} if reg.OpenKey(s + '\shell\open\command', false) false then {The open command has been found} s := reg.ReadString(''); reg.CloseKey; end; end; end; {Delete any command line, quotes and spaces} if Pos('%', s) 0 then Delete(s, Pos('%', s), length(s)); if Pos('/', s) 0 then Delete(s, Pos('/', s), length(s)); // delete switches if Pos('-', s) 0 then Delete(s, Pos('-', s), length(s)); // delete switches if ((length(s) 0) and (s[1] = '')) then Delete(s, 1, 1); if ((length(s) 0) and (s[length(s)] = '')) then Delete(s, Length(s), 1); while ((length(s) 0) and ((s[length(s)] = #32) or (s[length(s)] = ''))) do Delete(s, Length(s), 1); result := s; end; Neil - Original Message - From: Robert Meek [EMAIL PROTECTED] To: delphi@elists.org Date: Mon, 19 May 2008 06:10:45 -0400 Subject: Help w/Registered File Types Morning all, I have an urgent need that I hope someone here can help me figure out how to handle, involving how to find out the full path and filename of an application via it being the registered file type for a selected data file! In my application, the user selects a data file, for example a .doc file which on most systems will be registered to open with Microsoft Word. How can my application find out if it has a registered application, what its registered application is, and return the path and filename of it to the user without actually launching the data file? Thanx in advance for any help! from Robert Meek dba Tangentals Design e-mail: [EMAIL PROTECTED] Freelance Windows Programming for XP and Vista Also proud to be a Moderator of the Delphi-List at elists.org Reality cannot be explained...only enjoyed or endured as your current perspective allows! ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
RE: Help w/Registered File Types
Haven't done this in many years and have no clue where the old code is, but what you want to look at are Delphi OLE Automation Servers. Here's a starting point: http://delphi.about.com/od/kbcontrolole/ss/word_automation.htm I believe it is addressed in serveral of the old standard Delphi books, (Calvert, etc.), so you might want to start there for whole coding examples. Jerry -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Meek Sent: Monday, May 19, 2008 6:11 AM To: delphi@elists.org Subject: Help w/Registered File Types Morning all, I have an urgent need that I hope someone here can help me figure out how to handle, involving how to find out the full path and filename of an application via it being the registered file type for a selected data file! In my application, the user selects a data file, for example a .doc file which on most systems will be registered to open with Microsoft Word. How can my application find out if it has a registered application, what its registered application is, and return the path and filename of it to the user without actually launching the data file? Thanx in advance for any help! from Robert Meek dba Tangentals Design e-mail: [EMAIL PROTECTED] ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
Re: Help w/Registered File Types
Robert Meek wrote: In my application, the user selects a data file, for example a .doc file which on most systems will be registered to open with Microsoft Word. How can my application find out if it has a registered application, what its registered application is, and return the path and filename of it to the user without actually launching the data file? Have a look at the AssocQueryString function and related functions. -- Rob ___ Delphi mailing list - Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi