Solved

Open My Computer

Posted on 2002-07-26
7
219 Views
Last Modified: 2010-04-04
How do i run My Computer?
0
Comment
Question by:easysoft_studios
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 50 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now