Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

I need help with file registering

Hi guys and girls,
I am developing a program in Delphi and I want some help:
How can I register a file type in M$-Windows. For example how can I make Windows open .xxx files with my program?

I hope you help me!

Comments

  • Mk. IIMk. II Member Posts: 16
    : Hi guys and girls,
    : I am developing a program in Delphi and I want some help:
    : How can I register a file type in M$-Windows. For example how can I make Windows open .xxx files with my program?
    :
    [code]
    procedure TfrmRegister.RegisterFileType(prefix: string; exepath: string; description: string; iconpath: string);
    var
    reg: TRegistry;
    begin
    reg := TRegistry.Create;
    try
    reg.RootKey := HKEY_CLASSES_ROOT;
    reg.OpenKey( '.' + prefix, True );
    try
    reg.WriteString( '', description );
    finally
    reg.CloseKey;
    end;
    reg.CreateKey( description );
    reg.OpenKey( description + 'DefaultIcon', True );
    try
    reg.WriteString( '', iconpath + ',0' )
    finally
    reg.CloseKey;
    end;
    if exepath <> '' then
    begin
    reg.OpenKey( description + 'shellopencommand', True );
    try
    reg.WriteString( '', exepath + ' "%1"' )
    finally
    reg.CloseKey;
    end;
    end;
    finally
    reg.Free;
    end;
    SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil );
    ShowMessage( 'Filetype *.' + prefix + ' registered' );
    end;
    [/code]

    to be called like this:

    [code]
    RegisterFileType
    (
    'abc', // prefix
    Application.ExeName, // path to executable
    'ABC File', // file type description
    ExtractFilePath(Application.ExeName) + 'abc.ico' // path to iconfile
    );
    [/code]

    done!


  • Shawn CarterShawn Carter Member Posts: 0

    __ // http://forcoder.org // free video tutorials and ebooks about { Ruby, Swift, JavaScript, Visual Basic .NET, MATLAB, PL/SQL, C, C#, Visual Basic, Go, PHP, Delphi, C++, Java, R, Perl, Objective-C, Python, Assembly, Scratch Kotlin, Ada, SAS, Bash, Clojure, VBScript, Fortran, Julia, Logo, Rust, ML, Transact-SQL, Awk, LabVIEW, Alice, Lisp, ABAP, Apex, COBOL, Hack, D, F#, Scheme, Prolog, Scala, Crystal, Lua, FoxPro, Dart, Erlang } ______________

Sign In or Register to comment.