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