Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Registering a file type on Windows 9x/2000/NT
This article has not been rated yet. After reading, feel free to leave comments and rate it.
This is typically the task of an installer like Wise or InstallShield, buy you may be in a situation where you have to do it manually.
Registering an application to handle a certain file type means putting a few entries in the registry. Just use the function from the code below.  | |  | | program RegisterExt;
uses
Registry;
procedure RegisterExtension(
const sAppName: String;
const sAppPath: String;
const sIconName: String;
const sExtension: String);
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
with Reg do
begin
RootKey := HKEY_CLASSES_ROOT;
OpenKey('.ext', True);
WriteString('', sAppName);
CloseKey;
OpenKey(sAppName, True);
WriteString('', sAppName);
OpenKey('DefaultIcon', True);
WriteString('', sIconName);
CloseKey;
OpenKey(sAppName+'\shell\open\command', True);
WriteString('', sAppPath);
CloseKey;
Free;
end ;
end;
begin
RegisterExtension('MyGreatApplication',
'c:\program files\mystuff\myApp.exe',
'c:\program files\mystuff\myApp.ico',
'.shl');
end. | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|
|
|
|
Cannot be correct. What happens to the parameter 'sExtension' ?
|
|