Solved

Execute explorer.exe ????

Posted on 1999-01-20
11
547 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
11 Comments
 
LVL 3

Expert Comment

by:Ronald Buster
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
>> 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
Comment Utility
Super, it works ! You've answered the question Madshi.
Please answer it (:-)
0
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.

 
LVL 20

Accepted Solution

by:
Madshi earned 10 total points
Comment Utility
Thank you...   :-)
0
 

Expert Comment

by:silvamv
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Madshi, could you give a sample ? How I use CreateProcess to do it ?
Thank's a lot.
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 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

17 Experts available now in Live!

Get 1:1 Help Now