Solved

Execute explorer.exe ????

Posted on 1999-01-20
11
552 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 102
Tviruailstringtree sort multi columns on header click 1 74
How to Get Images From Server using App Tethering 11 39
MS Access from Delphi 31 60
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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