ShellExecute - open file with default application lazarus / 13-General ---------------------------------------------------------------------- Anonymous · 2005-10-05 22:04 I'd like to use ShellExecute to open a file with the default application. I can get it to run a program, but not to open a file. The code snippet below works - it runs the program md5.exe Code: [Select]     s := 'C:\Programs\md5.exe';     i := ShellExecute(Form1.Handle, PChar ('open'), PChar (s), PChar (''), PChar (''), 0); The value of i is always a value greater than 32 (it was 42 the last time I ran it) The code snippet below does not work - nothing appears to happen. The file C:\PDFCreator-Errorlog.txt is a simple text file. If you double- click on it in Windows Explorer, it opens in Notepad. Code: [Select]     s := 'C:\PDFCreator-Errorlog.txt';     i := ShellExecute(Form1.Handle, PChar ('open'), PChar (s), PChar (''), PChar (''), 0); It returns a value of 5 if it is run from within Lazarus' IDE. However, if I compile the program and run it by double-clicking on the .exe file, it still doesn't work, but it returns a value of 42. Any ideas? I'm using Lazarus 0.9.10 beta (2 Oct 2005) on Windows XP SP2 Russ ---------------------------------------------------------------------- Anonymous · 2005-12-02 19:03 // try unsing 1 instead 0 at the end of shellexecute... it worked for me!!!! procedure TForm1.Button2Click(Sender: TObject); var s:string;     i:longint; begin     s := 'text.txt';     i := ShellExecute(Form1.Handle, PChar ('open'), PChar (s),          PChar (''), PChar (''), 1); end;