Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Click a file and launch my app - how to? 1

Status
Not open for further replies.

sjwales

MIS
Jun 24, 2003
61
US
My application writes out files with a *.dek file type. I've had a request from my users to be able to double click on these files, launch my app and open and process the file.

My questions are, then:

(a) How do I associate this file type with my app? I assume that there a Registry setting that I need to change (I can do that programmatically if I know what to change... )

(b) When my program launches, how can I tell that it was from double clicking that file (so that I can then enter into datafile open/read/process logic)?

Thanks

stephen.wales@riotinto.com
 
Oh, and if it matters, I'm using D5 Pro.

Thanks

stephen.wales@riotinto.com
 
OK, this still isn't quite working.....

Here's the basis of the (snipped) code to set the Registry:

Code:
const
  BaseKey2 = '\.dek';
var
  DotDek, DfltApp : string;

begin
  RegFile := TRegistry.Create;
  RegFile.RootKey := HKEY_CLASSES_ROOT;

  with RegFile do begin
    OpenKey(BaseKey2,True);
    DotDek := ReadString('Default');
    if trim(DotDek) = '' then begin
      WriteString('(Default)','WCE.Deck');
    end;
    CloseKey;
    OpenKey(BaseKey3,True);
    DfltApp := ReadString('Default');
    WriteString('(Default)',ExtractFilePath(Application.ExeName) + 'warlordce.exe %1');
    CloseKey;
  end;
end;

When done, HKEY_CLASSES_ROOT\.dek contains two entries that seem duplicates to me:

(Default) value not set
(Default) WCE.Deck

Apparently there's a string (Default) as well as the default (Default) - if you get what I'm meaning. How do I update the default (Default) and change "value not set" to "WCE.DEck"

Thanks

stephen.wales@riotinto.com
 
Worked it out.

Do:
Value := ReadString('');

Or:
WriteString := ('', 'NewValue');


That's how you access the (Default) key in the Registry.

Thanks

stephen.wales@riotinto.com
 
You will also need to put something like this in your code:

procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.LoadFromFile(ParamStr(1));
end;

PARAMSTR(i) returns the command line parametre at index number i.

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top