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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DblClick a Filename & auto open it in appropriate browser?

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi All

I have an interface which displays different filenames (with filepaths). If a user double clicks or presses a button, is it possible to auto open the correct browser with the file just by using the filename?

I've tried this but keep getting a result <= 32.

if ShellExecute(Handle, 'open', nil, pchar(pnlfilename.caption), nil, SW_SHOW) <= 32 then ...

if ShellExecute(Handle, 'open', pchar(pnlfilename.caption), nil, nil, SW_SHOW) <= 32 then ...

many thanks for help,
lou
 
Do you have an application associated with the file type you are trying to "open".

The second of your two ShellExecute calls should work.

I do this kind of thing quite a lot but I usually define the editor that I want to use as well as the file I want opened:
Code:
  ShellExecute ( 0, 'Open', pchar(Editor), pchar(filename), pchar(''), SW_HIDE );

Andrew
Hampshire, UK
 
hi Andrew

There can be several different file extensions (common ones like .txt, .htm, .doc etc).

I did try the following and it worked so don't know what's wrong with the other bit, the filename looks valid in the caption.

This worked:-

ShellExecute(Handle, 'open', pchar('c:\temp\tester.txt'), nil, nil, SW_SHOW)

lou
 
Which filename didn't work and what was the actual ShellExecute statement that failed?

Can you give the exact error code returned by ShellExecute?

Andrew
Hampshire, UK
 
hi Andrew

This is the line and it now works with Trim in there. I guess some control character must have been in there:

res := ShellExecute(FmMain.Handle, 'open', pchar(trim(pnlfilename.caption)), nil, nil, SW_SHOW);


Thanks for all your help,
lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top