?
Solved

Execute explorer.exe ????

Posted on 1999-01-20
11
Medium Priority
?
562 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 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