Recent

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

majid.ebru

  • Sr. Member
  • ****
  • Posts: 408
[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

  • New Member
  • *
  • Posts: 42
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: 408
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: 602
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;  
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

majid.ebru

  • Sr. Member
  • ****
  • Posts: 408
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