Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Adding extension support in programms Posted by porodoro on 5 Feb 2006 at 1:14 AM
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


Report
Re: Adding extension support in programms Posted by zibadian on 5 Feb 2006 at 1:35 AM
: 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\{Extension}\Shell\Open\Command
The value of this key must be set to a string describing the DOS command to open your program. For example:
"{program filename (incl. path)}.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.
Report
Re: Adding extension support in programms Posted by porodoro on 5 Feb 2006 at 4:06 AM
: : 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\{Extension}\Shell\Open\Command
: The value of this key must be set to a string describing the DOS command to open your program. For example:
: "{program filename (incl. path)}.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_TEST\Shell\Open\Command');
REG.OpenKey('\.EXT_TEST\Shell\Open\Command',true);
Reg.WriteString('Command','"' + ParamStr(0) + '"' + ' "%1"' );

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



Report
Re: Adding extension support in programms Posted by zibadian on 5 Feb 2006 at 4:37 AM
: : : 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\{Extension}\Shell\Open\Command
: : The value of this key must be set to a string describing the DOS command to open your program. For example:
: : "{program filename (incl. path)}.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_TEST\Shell\Open\Command');
: REG.OpenKey('\.EXT_TEST\Shell\Open\Command',true);
: Reg.WriteString('Command','"' + ParamStr(0) + '"' + ' "%1"' );
:
: Can you write an example ? including how to add description ?
: Thanks!
:
This is my working test code:
  Reg := TRegistry.Create;
  with Reg do try
    RootKey := HKEY_CLASSES_ROOT;
    CreateKey('\.EXT_TEST\Shell\Open\Command');
    OpenKey('\.EXT_TEST\Shell\Open\Command',true);
    WriteString('','"' + ParamStr(0) + '"' + ' "%1"' );
  finally
    Free;
  end;

Notice the difference between the WriteString() calls.
As for the description. That will need to be done using the more elaborate method I described.
Report
Re: Adding extension support in programms Posted by porodoro on 5 Feb 2006 at 11:58 AM
: : : : 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\{Extension}\Shell\Open\Command
: : : The value of this key must be set to a string describing the DOS command to open your program. For example:
: : : "{program filename (incl. path)}.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_TEST\Shell\Open\Command');
: : REG.OpenKey('\.EXT_TEST\Shell\Open\Command',true);
: : Reg.WriteString('Command','"' + ParamStr(0) + '"' + ' "%1"' );
: :
: : Can you write an example ? including how to add description ?
: : Thanks!
: :
: This is my working test code:
:
:   Reg := TRegistry.Create;
:   with Reg do try
:     RootKey := HKEY_CLASSES_ROOT;
:     CreateKey('\.EXT_TEST\Shell\Open\Command');
:     OpenKey('\.EXT_TEST\Shell\Open\Command',true);
:     WriteString('','"' + ParamStr(0) + '"' + ' "%1"' );
:   finally
:     Free;
:   end;
: 

: 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;


Report
Re: Adding extension support in programms Posted by porodoro on 5 Feb 2006 at 12:15 PM
I fixed it ..

:) thanks for your great HELP!
Report
Re: Adding extension support in programms Posted by zibadian on 5 Feb 2006 at 12:30 PM
: 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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.