Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Creating a file association for my application?


How do I create a file association for my application?   

    In Win32, create a new registry entry under the HKEY_CLASSES_ROOT root key that points to the file extension, the command line to invoke, and the icon to display. Under Win 6, simply file extension and the command line to invoke in the [Extensions] sections of Win.ini.

    Example:

    uses Registry, {For Win32} IniFiles; {For Win 6}

    {For Win32} procedure TForm .Button Click(Sender: TObject); var reg: TRegistry; begin reg := TRegistry.Create; reg.RootKey := HKEY_CLASSES_ROOT; reg.LazyWrite := false; {Add Program Support} reg.OpenKey('.bor\shell\open\command', true); {Invoke the program passing the file name as the first parameter} reg.WriteString('', 'C:\Program Files\Borland\Delphi 3\Project .exe % '); {Add Icon Display} reg.CloseKey; reg.OpenKey('.bor\DefaultIcon', true); {Use the first icon in the executable to display} reg.WriteString('', 'C:\Program Files\Borland\Delphi 3\Project .exe,0'); reg.CloseKey; reg.free; end;

    {For Win 6} procedure TForm .Button2Click(Sender: TObject); var WinIni : TIniFile; WinIniFileName : array[0..MAX_PATH] of char; s : array[0..64] of char; begin GetWindowsDirectory(WinIniFileName, sizeof(WinIniFileName)); StrCat(WinIniFileName, '\win.ini'); WinIni := TIniFile.Create(WinIniFileName); WinIni.WriteString('Extensions', 'bor', 'C:\PROGRA~ \BORLAND\DELPHI~ \PROJECT .EXE ^.bor'); WinIni.Free; StrCopy(S, 'Extensions'); SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@S)); end;

    7/ 6/98 4:3 :28 PM

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use