?
Solved

Execute explorer.exe ????

Posted on 1999-01-20
11
Medium Priority
?
561 Views
Last Modified: 2008-02-20
Hi,
I made my program to the windows explorer (system.ini
shell=myprogram.exe) how can my program start the explorer ?
shellexecute (... c:\windows\explorer.exe ...) starts the
filemanager ! Is there a parameter required ???
0
Comment
Question by:ItsMe
[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
11 Comments
 
LVL 3

Expert Comment

by:Ronald Buster
ID: 1362508
Hi Itsme,

Try this code hope it helps

regards,

Cono

<-------------------------------->

WinExec32('c:\windows\explorer.exe',0);

<-------------------------------->

function WinExec32(Filename:string; Visibility:integer) : integer;
var zAppName: array[0..512] of char;
    zCurDir : array[0..255] of char;
    Workdir : string;
    StartUpInfo : TStartUpInfo;
    ProcessInfo : TProcessInformation;
begin
  StrPCopy(zAppName,FileName);
  GetDir(0,Workdir);
  StrPCopy(zCurDir,Workdir);
  FillChar(StartUpInfo,SizeOf(StartUpInfo),#0);
  StartUpInfo.cb := SizeOf(StartUpInfo);
  StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartUpInfo.wShowWindow := Visibility;

  if not CreateProcess(nil,zAppName,nil,nil,false,
                       CREATE_NEW_CONSOLE or
                       NORMAL_PRIORITY_CLASS,
                       nil,nil,StartUpInfo,
                       ProcessInfo) then
    Result := -1
  else
    begin
//      WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
      GetExitCodeProcess(ProcessInfo.hProcess,Result);
    end;
end;
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362509
ItsMe, cono's answer won't help you.
You must do this:
(1) Set "shell=Explorer.Exe"
(2) Start Explorer.exe
(3) Wait, until it is completely started
(3) Set "shell=C:\YourPath\YourProgram.exe"

Regards, Madshi.
0
 

Author Comment

by:ItsMe
ID: 1362510
Madshi,
I want to write a login software which starts the explorer when
the login was correct. It wouldn't help me to start the explorer
first because nobody is allowed to access it during the time
my program is running. My program will change different system
settings after login and then starts explorer.exe but explorer
starts as fileman I guess there is a parameter ? Or must I only change the system.ini entry to explorer.exe before I start it ?

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Madshi
ID: 1362511
>> Or must I only change the system.ini entry to explorer.exe before I start it ?

You got it. That's what I tried to tell you with my last comment.

Regards, Madshi.
0
 

Author Comment

by:ItsMe
ID: 1362512
Super, it works ! You've answered the question Madshi.
Please answer it (:-)
0
 
LVL 20

Accepted Solution

by:
Madshi earned 40 total points
ID: 1362513
Thank you...   :-)
0
 

Expert Comment

by:silvamv
ID: 4622363
why this code does not work ?

procedure TForm1.Button1Click(Sender: TObject);
begin
  WritePrivateProfileString('boot','shell','explorer.exe','system.ini');  // flush ini
  WritePrivateProfileString(nil,nil,nil,'system.ini');  // flush ini
  shellexecute(0,nil,'explorer.exe',nil,nil,sw_show);
//  WritePrivateProfileString('boot','shell','myshell.exe','system.ini');  // flush ini
end;
0
 

Author Comment

by:ItsMe
ID: 4623403
hi silvamv,
perhaps you should give the whole path to shellexecute ? btw. what exactly doesn't work / what happens ?

regards
ItsMe
0
 
LVL 20

Expert Comment

by:Madshi
ID: 4626258
It should work without the path. But you need to wait until the explorer is fully loaded before you switch the shell setting back. Use one of this possibilities:

(1) Use CreateProcess instead of ShellExecute, then WaitForInputIdle(processInfo.hProcess). And don't forget to close the handles afterwards.
(2) Wait until the tray window is visible (IsWindowVisible(FindWindow('Shell_TrayWnd', ''));).

Regards, Madshi.
0
 

Expert Comment

by:mvsilva
ID: 4628183
Madshi, could you give a sample ? How I use CreateProcess to do it ?
Thank's a lot.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 4628343
Oh no, please. Can't you figure that out yourself? If not, please ask a new question. Look, this question had only 10 points. Now you want even additional help from me for the same 10 points I got from ItsMe...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 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