If you like how Windows Explorer and File Manager lets you open documents just by double clicking on them, without openning the associated program first, here's how to achieve similar functionality from your Delphi program:
program shellexe;
uses
WinTypes, ShellAPI;
procedure OpenObject( sObjectPath : string );
begin
ShellExecute( 0, Nil, PChar( sObjectPath ),
Nil, Nil, SW_NORMAL );
end;
begin
OpenObject( 'c:my_docsreport.txt' );
end.
uses
WinTypes, ShellAPI;
procedure OpenObject( sObjectPath : string );
begin
ShellExecute( 0, Nil, PChar( sObjectPath ),
Nil, Nil, SW_NORMAL );
end;
begin
OpenObject( 'c:my_docsreport.txt' );
end.
Listing #1 : Delphi code. Download shellexe (0.3 KB).
OpenObject( 'notepad.exe' );
Listing #2 : Delphi code. Download runexe (0.16 KB).