Solved

Execute explorer.exe ????

Posted on 1999-01-20
11
550 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
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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
Multiple image collision 13 74
Wincontrol not (correctly) drawn 15 38
Twebbrowser add css to the header 3 25
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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