Adding extension support in programms - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Adding extension support in programms

Hi , i'm looking for a code that writes registry values
and adds extension support for my programms.

For example :

I have a file called 'Test.MYEXT'

I want to launch my application after double clicking


Comments

  • zibadianzibadian Posts: 6,349Member
    : Hi , i'm looking for a code that writes registry values
    : and adds extension support for my programms.
    :
    : For example :
    :
    : I have a file called 'Test.MYEXT'
    :
    : I want to launch my application after double clicking
    :
    :
    :
    Accessing the registry is the easiest using the TRegistry object. Adding a simple extension involves the creation of a single key: HKEY_CLASSES_ROOT[italic]{Extension}[/italic]ShellOpenCommand
    The value of this key must be set to a string describing the DOS command to open your program. For example:
    "[italic]{program filename (incl. path)}[/italic].exe" "%1"

    Finally your program must have code to open a specified document using command-line parameters. This code usually involves calls to the ParamCount() and ParamStr() functions.
    The help files contain more info on the functions and objects. Using the registry editor you can find more examples.

    More advanced registrations involve creating a key for your extension, which gives the name of the filetype. The filetype name is also a key under the HKEY_CLASSES_ROOT, which describes what to do with that type. This can either be a Shell key as described above or a class GUID defining the interface handler. Obviously this handler also needs to be registered using either an installer or a self-registering class library.
  • porodoroporodoro Posts: 230Member
    : : Hi , i'm looking for a code that writes registry values
    : : and adds extension support for my programms.
    : :
    : : For example :
    : :
    : : I have a file called 'Test.MYEXT'
    : :
    : : I want to launch my application after double clicking
    : :
    : :
    : :
    : Accessing the registry is the easiest using the TRegistry object. Adding a simple extension involves the creation of a single key: HKEY_CLASSES_ROOT[italic]{Extension}[/italic]ShellOpenCommand
    : The value of this key must be set to a string describing the DOS command to open your program. For example:
    : "[italic]{program filename (incl. path)}[/italic].exe" "%1"
    :
    : Finally your program must have code to open a specified document using command-line parameters. This code usually involves calls to the ParamCount() and ParamStr() functions.
    : The help files contain more info on the functions and objects. Using the registry editor you can find more examples.
    :
    : More advanced registrations involve creating a key for your extension, which gives the name of the filetype. The filetype name is also a key under the HKEY_CLASSES_ROOT, which describes what to do with that type. This can either be a Shell key as described above or a class GUID defining the interface handler. Obviously this handler also needs to be registered using either an installer or a self-registering class library.
    :

    --
    i've tryed this , but it doesnt seems to work :

    reg.Create;
    Reg.RootKey := HKEY_CLASSES_ROOT;
    reg.CreateKey('.EXT_TESTShellOpenCommand');
    REG.OpenKey('.EXT_TESTShellOpenCommand',true);
    Reg.WriteString('Command','"' + ParamStr(0) + '"' + ' "%1"' );

    Can you write an example ? including how to add description ?
    Thanks!



  • zibadianzibadian Posts: 6,349Member
    : : : Hi , i'm looking for a code that writes registry values
    : : : and adds extension support for my programms.
    : : :
    : : : For example :
    : : :
    : : : I have a file called 'Test.MYEXT'
    : : :
    : : : I want to launch my application after double clicking
    : : :
    : : :
    : : :
    : : Accessing the registry is the easiest using the TRegistry object. Adding a simple extension involves the creation of a single key: HKEY_CLASSES_ROOT[italic]{Extension}[/italic]ShellOpenCommand
    : : The value of this key must be set to a string describing the DOS command to open your program. For example:
    : : "[italic]{program filename (incl. path)}[/italic].exe" "%1"
    : :
    : : Finally your program must have code to open a specified document using command-line parameters. This code usually involves calls to the ParamCount() and ParamStr() functions.
    : : The help files contain more info on the functions and objects. Using the registry editor you can find more examples.
    : :
    : : More advanced registrations involve creating a key for your extension, which gives the name of the filetype. The filetype name is also a key under the HKEY_CLASSES_ROOT, which describes what to do with that type. This can either be a Shell key as described above or a class GUID defining the interface handler. Obviously this handler also needs to be registered using either an installer or a self-registering class library.
    : :
    :
    : --
    : i've tryed this , but it doesnt seems to work :
    :
    : reg.Create;
    : Reg.RootKey := HKEY_CLASSES_ROOT;
    : reg.CreateKey('.EXT_TESTShellOpenCommand');
    : REG.OpenKey('.EXT_TESTShellOpenCommand',true);
    : Reg.WriteString('Command','"' + ParamStr(0) + '"' + ' "%1"' );
    :
    : Can you write an example ? including how to add description ?
    : Thanks!
    :
    This is my working test code:
    [code]
    Reg := TRegistry.Create;
    with Reg do try
    RootKey := HKEY_CLASSES_ROOT;
    CreateKey('.EXT_TESTShellOpenCommand');
    OpenKey('.EXT_TESTShellOpenCommand',true);
    WriteString('','"' + ParamStr(0) + '"' + ' "%1"' );
    finally
    Free;
    end;
    [/code]
    Notice the difference between the WriteString() calls.
    As for the description. That will need to be done using the more elaborate method I described.
  • porodoroporodoro Posts: 230Member
    : : : : Hi , i'm looking for a code that writes registry values
    : : : : and adds extension support for my programms.
    : : : :
    : : : : For example :
    : : : :
    : : : : I have a file called 'Test.MYEXT'
    : : : :
    : : : : I want to launch my application after double clicking
    : : : :
    : : : :
    : : : :
    : : : Accessing the registry is the easiest using the TRegistry object. Adding a simple extension involves the creation of a single key: HKEY_CLASSES_ROOT[italic]{Extension}[/italic]ShellOpenCommand
    : : : The value of this key must be set to a string describing the DOS command to open your program. For example:
    : : : "[italic]{program filename (incl. path)}[/italic].exe" "%1"
    : : :
    : : : Finally your program must have code to open a specified document using command-line parameters. This code usually involves calls to the ParamCount() and ParamStr() functions.
    : : : The help files contain more info on the functions and objects. Using the registry editor you can find more examples.
    : : :
    : : : More advanced registrations involve creating a key for your extension, which gives the name of the filetype. The filetype name is also a key under the HKEY_CLASSES_ROOT, which describes what to do with that type. This can either be a Shell key as described above or a class GUID defining the interface handler. Obviously this handler also needs to be registered using either an installer or a self-registering class library.
    : : :
    : :
    : : --
    : : i've tryed this , but it doesnt seems to work :
    : :
    : : reg.Create;
    : : Reg.RootKey := HKEY_CLASSES_ROOT;
    : : reg.CreateKey('.EXT_TESTShellOpenCommand');
    : : REG.OpenKey('.EXT_TESTShellOpenCommand',true);
    : : Reg.WriteString('Command','"' + ParamStr(0) + '"' + ' "%1"' );
    : :
    : : Can you write an example ? including how to add description ?
    : : Thanks!
    : :
    : This is my working test code:
    : [code]
    : Reg := TRegistry.Create;
    : with Reg do try
    : RootKey := HKEY_CLASSES_ROOT;
    : CreateKey('.EXT_TESTShellOpenCommand');
    : OpenKey('.EXT_TESTShellOpenCommand',true);
    : WriteString('','"' + ParamStr(0) + '"' + ' "%1"' );
    : finally
    : Free;
    : end;
    : [/code]
    : Notice the difference between the WriteString() calls.
    : As for the description. That will need to be done using the more elaborate method I described.
    :
    Okay it worked .

    But now im having problem with loading the .ini configuration file.
    (An access violation errors appears) :

    for x:=0 to PARAMCOUNT do begin
    if (fileexists(ParamStr(X)) )
    and not
    (paramstr(X)= Application.Exename)
    then begin

    loadconfigfile(ParamStr(X));
    openfile.FileName:=ParamStr(X);
    end;


  • porodoroporodoro Posts: 230Member
    I fixed it ..

    :) thanks for your great HELP!
  • zibadianzibadian Posts: 6,349Member
    : I fixed it ..
    :
    : :) thanks for your great HELP!
    :
    You could better start the loop at 1. ParamStr(0) is always the filename of the program, while ParamStr(1) is the first "real" parameter.
Sign In or Register to comment.