他のアプリを起動する
他のアプリケーションを起動するには ShellExecuteを使用します。
この関数では Exeファイル以外にも他のアプリに関連付けられたファイルの起動もできます。使用する際は uses節に ShellAPI
を追加してください。
| ■ 他のアプリを起動する例 |
procedure TForm1.Button1Click(Sender: TObject);
const
strExeName = 'c:\windows\Notepad.exe';
strDocName = 'd:\borland\Delphi 3\Readme.txt';
begin
if RadioButton1.Checked then
begin
{ メモ帳を起動 }
ShellExecute(Handle,'open',PChar(strExeName),'',
PChar(ExtractFilePath(Application.Exename)),SW_SHOWDEFAULT);
end else begin
{ Readmeを関連付けを元に起動 }
ShellExecute(Handle,'open',PChar(strDocName),'',
PChar(ExtractFilePath(Application.Exename)),SW_SHOWDEFAULT);
end;
end;
|