星期四, 11月 11, 2010

開啟檔案,若失敗就跳出選擇關聯程式清單


if OpenDialog1.execute then
begin
if ShellExecute(handle, 'Open', PChar(OpenDialog1.FileName), nil, nil, SW_NORMAL) = SE_ERR_NOASSOC then
ShellExecute(GetDesktopWindow, nil, 'RUNDLL32.EXE',
PChar('shell32.dll, OpenAs_RunDLL ' + OpenDialog1.FileName),
PChar(ExtractFilePath(ParamStr(0))), SW_NORMAL);
end;