Recent

Author Topic: [Solved] How to open Folder and select item?  (Read 606 times)

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
[Solved] How to open Folder and select item?
« on: June 07, 2022, 05:44:57 am »
Hi dear

When I right-click an icon on the Windows desktop and open the file location, I go to the destination folder and then to the selected icon.
how can i implement this?
I can only open a folder or open a program like these code:
Code: Pascal  [Select][+][-]
  1.   OpenURL(edtDirectory.Text+'\'+Rd_Name);
  2.   SysUtils.ExecuteProcess(UTF8ToSys('explorer.exe'), stg100.Cells[2,stg100.Row], \['\']);// <= what is this ???
  3.   WinExec(PChar('explorer.exe /e,'+ stg100.Cells[2,stg100.Row]),SW_SHOWNORMAL);
  4.  
but I can't select the target icon?
« Last Edit: June 07, 2022, 10:50:17 am by majid.ebru »

Coldzer0

  • Jr. Member
  • **
  • Posts: 50
Re: How to open Folder and select item?
« Reply #1 on: June 07, 2022, 06:40:01 am »
Here's a very simple way of doing this  8)

Code: Pascal  [Select][+][-]
  1. Program OpenFileLocation;
  2.  
  3. Uses
  4.   Windows,
  5.   shlobj,
  6.   ActiveX;
  7.  
  8. Var
  9.   SelectedFile : LPITEMIDLIST;
  10. Begin
  11.   CoInitializeEx(nil, COINIT_MULTITHREADED);
  12.   Try
  13.     SelectedFile := ILCreateFromPath('C:\Windows\System32\cmd.exe');
  14.     If SelectedFile <> nil Then
  15.     Begin
  16.       SHOpenFolderAndSelectItems(SelectedFile, 0, SelectedFile, 0);
  17.       ILFree(SelectedFile);
  18.     End;
  19.   Finally
  20.     CoUninitialize;
  21.   End;
  22. End.
  23.  

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
Re: How to open Folder and select item?
« Reply #2 on: June 07, 2022, 10:49:33 am »
thank you Coldzer0 ;D ;D ;D ;D


but i should change this code:
Code: Pascal  [Select][+][-]
  1. SelectedFile := ILCreateFromPath(PChar( myAddress ));
  2.  
:) ;) :D

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: [Solved] How to open Folder and select item?
« Reply #3 on: June 07, 2022, 11:17:39 am »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.    ExecuteProcess('explorer.exe', '/select,'+PChar('C:\Windows\System32\cmd.exe'), []);
  4. end;  
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
Re: [Solved] How to open Folder and select item?
« Reply #4 on: August 10, 2022, 01:07:47 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.    ExecuteProcess('explorer.exe', '/select,'+PChar('C:\Windows\System32\cmd.exe'), []);
  4. end;  

thank you

but last code is faster that this code

 

TinyPortal © 2005-2018