Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Open My Computer

Posted on 2002-07-26
7
Medium Priority
?
227 Views
Last Modified: 2010-04-04
How do i run My Computer?
0
Comment
Question by:easysoft_studios
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:PeterZG
ID: 7181363
?
0
 

Author Comment

by:easysoft_studios
ID: 7181366
Like then you click at the My Computer icon on the desktop.
0
 
LVL 1

Expert Comment

by:PeterZG
ID: 7181395
do you want to simulate clicking the icon (shortcut) or open it within your own application?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Expert Comment

by:ginsonic
ID: 7181569
uses ShellApi,ShlObj;

procedure TForm1.Button1Click(Sender: TObject);
var
   PIDL:PItemIDList;
   Info:TShellExecuteInfo;
   pInfo:PShellExecuteInfo;
   WaitCode:DWord;
begin
   SHGetSpecialFolderLocation(Handle,CSIDL_DRIVES,PIDL);
   pInfo:=@Info;
   With Info do begin
    cbSize:=SizeOf(Info);
    fMask:=SEE_MASK_NOCLOSEPROCESS+SEE_MASK_IDLIST;
    wnd:=Handle;
    lpVerb:=nil;
    lpFile:=nil;
    lpParameters:=nil;
    lpDirectory:=nil;
    nShow:=SW_ShowNormal;
    hInstApp:=0;
    lpIDList:=PIDL;
   end;
   ShellExecuteEx(pInfo);
   repeat
    WaitCode := WaitForSingleObject(Info.hProcess,500);
    Application.ProcessMessages;
   until (WaitCode <> WAIT_TIMEOUT);
end;

 
0
 
LVL 2

Expert Comment

by:Tasomia
ID: 7181653
uses ShellApi, ShlObj, ActiveX;

procedure TForm1.Button1Click(Sender: TObject);
var
  PIDL: PItemIDList;
  Info: TShellExecuteInfo;
  pInfo: PShellExecuteInfo;
  WaitCode: DWORD;
  Allocator: IMalloc;
begin
  if SHGetMalloc(Allocator) = NOERROR then
  begin
    SHGetSpecialFolderLocation(Handle, CSIDL_DRIVES, PIDL);
    Allocator.Free(PIDL);
    pInfo := @Info;
    ZeroMemory(@Info, SizeOf(Info));
    with Info do
    begin
      cbSize := SizeOf(Info);
      fMask := SEE_MASK_NOCLOSEPROCESS + SEE_MASK_IDLIST;
      wnd := Handle;
      lpVerb := nil;
      lpFile := nil;
      lpParameters := nil;
      lpDirectory := nil;
      nShow := SW_SHOWNORMAL;
      hInstApp := 0;
      lpIDList := PIDL;
    end;
    ShellExecuteEx(pInfo);
    repeat
      WaitCode := WaitForSingleObject(Info.hProcess, 500);
      Application.ProcessMessages;
    until (WaitCode <> WAIT_TIMEOUT);
  end;
end;
0
 
LVL 20

Accepted Solution

by:
Madshi earned 150 total points
ID: 7181674
ginsonic's code doesn't free the pidl -> memory leak!

Tasomia's code does free the pidl, but too early, you're freeing it before it is actually used.

This one works fine on my XP, didn't test it under other OSs, though:

  WinExec('explorer.exe ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}', SW_SHOWNORMAL);

Regards, Madshi.
0
 

Author Comment

by:easysoft_studios
ID: 7181913
I it supposed to work on XP, so Madshi's lookes fine. I'll return when i'm sitting with my IDE running :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question