?
Solved

Restarting Explorer.exe without taskbar items un-minimising.

Posted on 2005-03-13
18
Medium Priority
?
585 Views
Last Modified: 2008-01-09
Hi all,  

I want to restart explorer programaticly... fine, the code below works fine.

HWND hwndShell = FindWindow("Progman", NULL);  
PostMessage(hwndShell, WM_QUIT, 0, 0L);  
WinExec("Explorer.exe",SW_SHOW);

BUT when the icons reappear on the desktop any loaded programs in the task bar (bottom right minimised to an icon) load in turn as their original un-minimised window.

Is there a cleaner way to restart explorer to make it look seemless?

Thanks in advance
(using windows 2000 pro)
0
Comment
Question by:chulland
[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
  • 6
  • 5
  • 4
  • +1
18 Comments
 
LVL 22

Expert Comment

by:grg99
ID: 13534031
Suspect you mean "Seamless".    

Maybe try using system() instead of WinExec()?



0
 

Author Comment

by:chulland
ID: 13535336
Yes I mean Seamless... spelling not one of my good points.

Can you please expain your comment?  I could use ShellExecute() on Explorer to do the same job.  Would still load up the icons as if you double clicked them.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 13536395
You could try to refresh the desktop rather than restart it:

    HWND hwndShell = ::FindWindow("Progman", NULL);  
    ::ShowWindow(hwndShell, SW_HIDE);
    ::ShowWindow(hwndShell, SW_SHOWNOACTIVATE);

Regards, Alex

0
Technology Partners: 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 39

Expert Comment

by:itsmeandnobodyelse
ID: 13536446
Instead of searching "Progman" you might use HWND_DESKTOP (or NULL) to automatically getting the handle of the current desktop.

0
 
LVL 22

Expert Comment

by:grg99
ID: 13536575
I've used system() dozens of times and it has never had any effect on the desktop.  

0
 
LVL 22

Expert Comment

by:grg99
ID: 13536605
Oh, sorry, I misunderstood your question!   I thought you wanted to restart YOUR program.

Perhaps we should ask:  WHY do you want to restart Explorer?     Restarting the main user interface to the OS is a rather drastic thing to do.

0
 

Author Comment

by:chulland
ID: 13537542
I require to restart explorer because I have made changes to the shell.  So refreshing the desktop is no good, I need a reload.

Many programs when installing new software require a shell reload whether its to load a dll into the explorer or whatever.

My question remains the same.  The initial code works but the loaded software minimized (bottom right icons), open up when desktop reloads.

Thanks
0
 
LVL 22

Expert Comment

by:grg99
ID: 13537638
Are you going to be changing the shell that often that this matters?     :)

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 13537646
>>>> Many programs when installing new software require a shell reload

No, I never heard of of such a thing beside of a reboot. "shell reload" is a UNIX kind of expression and is no common Windows practice.

Dlls, services and drivers are not loaded by Explorer but by Windows. Restarting the explorer will refresh icons, explorer contents menu, some other explorer settings like "Send To..." ... and nothing else. All this will happen automatically as well within some seconds delay, e. g. if you are adding icon links to "All Users\start menu\program files\".

So, I would be interested in your "changes to the shell" that need a restart of the explorer.

Regards, Alex

0
 

Author Comment

by:chulland
ID: 13537727
LOL what is the problem here guys.... I am asking a simple question that require a simple answer (I hope)

WHY I am wanting the restart is not an issue. Even Microsoft offer the solution:-
http://support.microsoft.com/support/kb/articles/Q137/5/72.ASP

BUT it does have this wierd side effect of unminimizing the loaded programs, or reloading them at normal window size.  

Other people do it perfectly, my code doesn't.

The question is why? What am I doing wrong.

Thanks



0
 

Author Comment

by:chulland
ID: 13537822
As for what explorer does, well itsmeandnobodyelse perhaps you have never written shell extensions before?  Explorer does a hell of a lot more than you think by your last comment.  It basically does ANYTHING that I want it to with a "plugin".  ANY DLL can be loaded in there at startup.

Many companies add pugins to exporer and have to restart hence my question.
0
 
LVL 22

Expert Comment

by:grg99
ID: 13537951
Here's a hint from the great unwashed out there:

 You can control whether Explorer will restore windows which were open when NT was shutdown. This automatic restoring of windows drives me nuts. It was a problem in OS/2, Windows NT, and now Windows 2000. You don't like it, fix it with the following Windows NT / Windows 2000 registry hack :

Hive: HKEY_CURRENT_USER
Key: Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
Name: NoSaveSettings
Type: REG_BINARY
Value: 1
This entry will prevent you from permanently repositioning desktop shortcuts and from adjusting the size and/or position of the Taskbar.

0
 

Author Comment

by:chulland
ID: 13537998
mmmm not sure if this is what I mean, I have seen something on this before.  My icons remain in the same place, the reload of explorer is perfect but any programs that were loaded and minimized come out of their minimized state.

I'll have a look at this and see if it helps any.

Thanks
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 13542150
>>>> well itsmeandnobodyelse perhaps you have never written shell extensions before?

Yes, you are right. But I know a lot of Windows services, dll unload and load, and if you would tell what kind of refreshes you need, I most likely could help you.

One last suggestion before unsubscribing:

Before closing the explorer get the list of all toplevel applications in the taskbar by means of a call to EnumWindows. Find out which windows are minimized by ::IsIconic(hwnd) and save the the window title to be able to identify them later (I don't know whether the hwnd handle changes after restart of Explorer). After restarting the Explorer you could watch by means of EnumWindows which windows have been restored. Send  a WM_SYSCOMMAND + SC_MINIMIZE (WPARAM) message to them and they will minimize (again). Stop the watching if all minimized windows have been invoked.

Regards, Alex
0
 

Author Comment

by:chulland
ID: 14054193
Hi,

I was given the answer through Email from a guy whose product did exactly what I wanted to do after I contacted him.

Here's what he did:-

Kill the process 'explorer.exe' with OpenProcess and TerminateProcess API calls.
In order to find the right ProcessID, enumerate all processes in the system, until finding the 'explorer.exe'. On Windows 9x, use Toolhelp functions (Process32First and Process32Next). On Windows 2000/XP, use PSAPI library (EnumProcesses function)

Thanks
Please close this question.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 14526828
PAQed with no points refunded (of 250)

DarthMod
Community Support Moderator
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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 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