Статьи по Delphi (026)…
Как выделить файлы в Проводнике?
| Как выделить файлы в Проводнике? |
Просто открыть окно, и выделить в нём файлы|папки
Да в принципе путь то нам известен? Известен, посему делаем финт хвостом:
Code: Uses ..., SHDocVw; {©Drkb v.3(2007): www.drkb.ru}. Function OpenExplorerAndSelectFile(Path: String): Boolean; Function ParceURLName(const Value: String): String; Const. ScFilePath: array [0..7] of Char = ('f', 'i', 'l', 'e', ':', '/', '/', '/'); Begin. If CompareMem(@scFilePath[0], @Value[1], 8) then. Begin. Result := Copy(Value, 9, Length(Value)); Result := StringReplace(Result, '/', '\', [rfReplaceAll]); Result := StringReplace(Result, '%20', ' ', [rfReplaceAll]); Result := IncludeTrailingBackslash(Result); End. Else. Result := Value; End; Var. IShellWindow: IShellWindows; IWB: IWebBrowserApp; SpDisp: IDispatch; I: Integer; S, FilePath, FileName: String; Begin. Result := FileExists(Path); If not Result then Exit; FilePath := AnsiUpperCase(ExtractFilePath(Path)); FileName := ExtractFileName(Path); IShellWindow := CoShellWindows.Create; For I := 0 to iShellWindow.Count - 1 do. Begin. SpDisp := iShellWindow.Item(I); If spDisp = nil then Continue; SpDisp.QueryInterface(IWebBrowserApp, iWB); If iWB <> nil then. Begin. S := ParceURLName(iWB.LocationURL); If AnsiUpperCase(S) = FilePath then. Begin. SendMessage(iWB.HWnd, WM_SYSCOMMAND, SC_CLOSE, 0); Break; End; End; End; ShellExecute(0, 'open', 'explorer.exe', PChar('/select, ' + FileName), PChar(FilePath), SW_SHOWNORMAL); End; Procedure TForm18.Button4Click(Sender: TObject); Begin. If not OpenExplorerAndSelectFile('c:\windows\notepad.exe') then. ShowMessage('Файл не найден.'); End;
Это проще чем искать по заголовку.
Взято из http://forum.sources.ru.
Автор: Rouse_
©Drkb::02390.
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.