473,469 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Shell Hooks and explorer.exe

11 New Member
I'm trying to write a replacement shell for Windows at the moment i have a working system tray and (sort-of) working taskbar.

The issue at the moment is the Taskbar is failing to receive window created/activated/destroyed messages when run on it's own.
If I run it on top of explorer it works fine. Even if i kill explorer and run it, it will work fine, but if a log into my user account with cmd.exe as shell and run it from there it receives no messages.

At the moment I'm using SetWindowsHookEx, Does this function rel on some other process to do it's job? or is there and alternative function that will do this job with the need for explorer to have run?
Dec 9 '08 #1
5 9374
Banfa
9,065 Recognized Expert Moderator Expert
What happens if you run your program as the shell as opposed to a command prompt?
Dec 9 '08 #2
RomeoPapacy
11 New Member
Thank you for your reply:

Same symptoms as when cmd is shell:
- Notification area works wonderfully
- Taskbar only seems to receive HSHELL_LANGUAGE messages
Dec 9 '08 #3
RomeoPapacy
11 New Member
If it will help, here is the code for the hook. This is compiled as a DLL using VC++ 2008 Express:
dllmain.cpp:
Expand|Select|Wrap|Line Numbers
  1. HINSTANCE hInst;
  2. BOOL APIENTRY DllMain( HMODULE hModule,
  3.                        DWORD  ul_reason_for_call,
  4.                        LPVOID lpReserved
  5.                      )
  6. {
  7.     switch (ul_reason_for_call)
  8.     {
  9.     case DLL_PROCESS_ATTACH:
  10.         hInst = (HINSTANCE) hModule;
  11.         break;
  12.     case DLL_THREAD_ATTACH:
  13.     case DLL_THREAD_DETACH:
  14.     case DLL_PROCESS_DETACH:
  15.         break;
  16.     }
  17.     return TRUE;
  18. }
  19.  
Hook.cpp:
Expand|Select|Wrap|Line Numbers
  1. extern HINSTANCE hInst;
  2. HWND callback=0;
  3. HHOOK hHook=0;
  4. std::fstream fLog("C:\\Logs\\Hook.log",std::fstream::out);
  5. HOOK_API void                SetHook(HWND hWnd){
  6.     hHook=SetWindowsHookEx(WH_SHELL,ShellProc,hInst,NULL);
  7. }
  8. LRESULT CALLBACK    ShellProc(int nCode, WPARAM wParam, LPARAM lParam){ 
  9.     if(nCode<0)return CallNextHookEx(hHook,nCode,wParam,lParam);
  10.     HWND h=FindWindow(TEXT("Shell_TrayWnd"),NULL);
  11.     fLog<<"Hook Message:"<<nCode<<endl;
  12.     switch(nCode){
  13.         case HSHELL_WINDOWCREATED:
  14.         case HSHELL_WINDOWACTIVATED:
  15.         case HSHELL_WINDOWDESTROYED:
  16.             PostMessage(h,WM_HOOKPROXY,(WPARAM)nCode,(LPARAM)wParam);
  17.             break;
  18.         case HSHELL_WINDOWREPLACED:
  19.             PostMessage(h,WM_HOOKPROXY,(WPARAM)HSHELL_WINDOWREPLACING,(LPARAM)wParam);
  20.             PostMessage(h,WM_HOOKPROXY,(WPARAM)HSHELL_WINDOWREPLACED,(LPARAM)wParam);
  21.             break;
  22.     }
  23.     return 0L;
  24. }; 
Dec 10 '08 #4
Banfa
9,065 Recognized Expert Moderator Expert
From the MSDN page on SetWindowsHookEh this paragraph seems relevant

Note that custom shell applications do not receive WH_SHELL messages. Therefore, any application that registers itself as the default shell must call the SystemParametersInfo function before it (or any other application) can receive WH_SHELL messages. This function must be called with SPI_SETMINIMIZEDMETRICS and a MINIMIZEDMETRICS structure. Set the iArrange member of this structure to ARW_HIDE.
I found it by Googling "WH_SHELL"
Dec 10 '08 #5
RomeoPapacy
11 New Member
Once again Banfa - you're a lifesaver
I must have read that page at least 5 times and never noticed that.

Thank you.
Dec 10 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Tom Dacon | last post by:
"Open .Net Command Window Here" context menu for Windows Explorer: The reg file described below adds a new menu item to Windows Explorer's context menu when you right-click over a folder (or the...
1
by: krose | last post by:
Hi Using a couple of examples on CodeProject.com I've create a nice little shell extension (adds some custom menus for proprietary file types). Everything is working fine, except I can't get it...
2
by: Sin | last post by:
Hello everyone, I'm totally stumped at how little info I can find in MSDN or on the web concerning this. It's almost as if only microsoft personel hold the key to these secrets or something!!! ...
1
by: jmi0 | last post by:
I want to create a custom user control to be used in a web page (by object tag) as an assembly. The user control needs to have a web browser control in it. Having tried with the managed...
6
by: Pieter | last post by:
Hi, I'm trying to use the Edanmo Shell Extension Library (http://www.mvps.org/emorcillo/en/code/shell/shellextensions.shtml) to make a Context Menu in the Windows Explorer with VB.NET 2005. It...
13
by: Hema | last post by:
hello all, I am working on a project related to Internet Explorer. I want my application to be invoked by a keypress( single key stroke or a combination). But this must get invoked only when the...
0
by: Hema | last post by:
hi all, i have implemented a keyboard hook which is active only when IE is open. Its a BHO. I am adding the code below: using System; using System.Runtime.InteropServices; using...
0
by: =?ISO-8859-15?Q?Jan_B=F6cker?= | last post by:
Hi, i want to write an app which has to log various user activity, such as opening folders and office documents, to help the user keep an overview about what open windows are related to one task...
0
by: vbcoder86 | last post by:
Hi All, I have an excel macro that I'm running. The code does everything I want except that after about 200 iterations VB will run out of memory and I'll get an "automation error". I'm using the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.