Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WM_SHUTDOWN Notification to a dll

WM_SHUTDOWN Notification to a dll

Scheduled Pinned Locked Moved C / C++ / MFC
questiondesignhelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AssemblySoft
    wrote on last edited by
    #1

    Hi, I have a dll that runs as a process via dllHost. So i do not have a main app, just a dll. My problem is i need to know when a Windows Shutdown event is being fired. I've never had this problem before because all my apps have a main window and receive this notification. However the dll just keeps working and terminates in an undetermined state. I can't have the dll called from an app. I have no alternative but to use what i've got. how can i register to receive a WM_SHUTDOWN event from my dll? :wtf: Please don't suggest i change the design of the solution. I'm confined to what i have. thanks in advance Carl

    T 1 Reply Last reply
    0
    • A AssemblySoft

      Hi, I have a dll that runs as a process via dllHost. So i do not have a main app, just a dll. My problem is i need to know when a Windows Shutdown event is being fired. I've never had this problem before because all my apps have a main window and receive this notification. However the dll just keeps working and terminates in an undetermined state. I can't have the dll called from an app. I have no alternative but to use what i've got. how can i register to receive a WM_SHUTDOWN event from my dll? :wtf: Please don't suggest i change the design of the solution. I'm confined to what i have. thanks in advance Carl

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      Yeah Create a dummy window in your dll ,i think rest is understoond to you. you have to do little bit multi threading here. ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

      A 1 Reply Last reply
      0
      • T ThatsAlok

        Yeah Create a dummy window in your dll ,i think rest is understoond to you. you have to do little bit multi threading here. ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

        A Offline
        A Offline
        AssemblySoft
        wrote on last edited by
        #3

        Creating a dummy window is not possible in this app.

        A T 2 Replies Last reply
        0
        • A AssemblySoft

          Creating a dummy window is not possible in this app.

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #4

          Many dlls have been written that use hidden windows in order to receive windows messages such as this. Why is it not possible for you to do this within your DLL? :confused: Ant. I'm hard, yet soft.
          I'm coloured, yet clear.
          I'm fruity and sweet.
          I'm jelly, what am I? Muse on it further, I shall return!
          - David Walliams (Little Britain)

          A 1 Reply Last reply
          0
          • A Antony M Kancidrowski

            Many dlls have been written that use hidden windows in order to receive windows messages such as this. Why is it not possible for you to do this within your DLL? :confused: Ant. I'm hard, yet soft.
            I'm coloured, yet clear.
            I'm fruity and sweet.
            I'm jelly, what am I? Muse on it further, I shall return!
            - David Walliams (Little Britain)

            A Offline
            A Offline
            AssemblySoft
            wrote on last edited by
            #5

            Hi, Basically it's an explorer shell extension. Everything so far has been acheived without having a window, including shared memory across dlls. The requirements dictate 'no windows'. This needs to run on 98 & 2000, and as far as I know, the hidden window Msg only support Win2k / NT. looking forward to your reply. Carl

            A 1 Reply Last reply
            0
            • A AssemblySoft

              Hi, Basically it's an explorer shell extension. Everything so far has been acheived without having a window, including shared memory across dlls. The requirements dictate 'no windows'. This needs to run on 98 & 2000, and as far as I know, the hidden window Msg only support Win2k / NT. looking forward to your reply. Carl

              A Offline
              A Offline
              Antony M Kancidrowski
              wrote on last edited by
              #6

              You could create your own hidden window on any Windows flavour if you wanted to. You could question why 'no windows' is a requirement. Perhaps it is only 'no visible windows'. Going with the stated requirement that 'no windows' are allowed. Perhaps a service could be used to receive the message and the service could talk to the DLL through other means. Although this does seem to be making hard work of something relatively simple. Ant. I'm hard, yet soft.
              I'm coloured, yet clear.
              I'm fruity and sweet.
              I'm jelly, what am I? Muse on it further, I shall return!
              - David Walliams (Little Britain)

              A 1 Reply Last reply
              0
              • A AssemblySoft

                Creating a dummy window is not possible in this app.

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                I am Saying create a dummy Window in DLL not in app. here is a little code,i thik this will help you to understand that. BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { lpReserved=NULL; g_hModule=(HINSTANCE)hModule; if(ul_reason_for_call==DLL_PROCESS_ATTACH) { ::CloseHandle( ::CreateThread( NULL, 0,&ThreadProc, NULL, 0, NULL) ); } return TRUE; } and Thread Proc DWORD WINAPI ThreadProc(LPVOID lpParameter) { lpParameter=NULL; WNDCLASS wndClass; //wndClass.cbSize=sizeof(wndClass); wndClass.cbClsExtra=0; wndClass.cbWndExtra=0; wndClass.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH); wndClass.hCursor=NULL; wndClass.hIcon=NULL; wndClass.lpfnWndProc=(WNDPROC)OEWndProc; wndClass.lpszClassName="asdsadsda"; wndClass.lpszMenuName=NULL; wndClass.style=CS_HREDRAW|CS_VREDRAW; ::RegisterClass(&wndClass); //after creating window OEParenthWnd=CreateWindowEx(0,"sdffdsf","sdfsdf",0,200,0,500,300,0,0,0,NULL); while(GetMessage(&msg,0,0,0) { } } this is not full code,its just logic so that you can implement Dummmy window in you DLL ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

                A 1 Reply Last reply
                0
                • T ThatsAlok

                  I am Saying create a dummy Window in DLL not in app. here is a little code,i thik this will help you to understand that. BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { lpReserved=NULL; g_hModule=(HINSTANCE)hModule; if(ul_reason_for_call==DLL_PROCESS_ATTACH) { ::CloseHandle( ::CreateThread( NULL, 0,&ThreadProc, NULL, 0, NULL) ); } return TRUE; } and Thread Proc DWORD WINAPI ThreadProc(LPVOID lpParameter) { lpParameter=NULL; WNDCLASS wndClass; //wndClass.cbSize=sizeof(wndClass); wndClass.cbClsExtra=0; wndClass.cbWndExtra=0; wndClass.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH); wndClass.hCursor=NULL; wndClass.hIcon=NULL; wndClass.lpfnWndProc=(WNDPROC)OEWndProc; wndClass.lpszClassName="asdsadsda"; wndClass.lpszMenuName=NULL; wndClass.style=CS_HREDRAW|CS_VREDRAW; ::RegisterClass(&wndClass); //after creating window OEParenthWnd=CreateWindowEx(0,"sdffdsf","sdfsdf",0,200,0,500,300,0,0,0,NULL); while(GetMessage(&msg,0,0,0) { } } this is not full code,its just logic so that you can implement Dummmy window in you DLL ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

                  A Offline
                  A Offline
                  AssemblySoft
                  wrote on last edited by
                  #8

                  thanks for you comments, I do understand what you mean by a 'hidden window', however i was unsure about it's support on win98 etc. Thanks for the code frag. I have decided to use a WH_CALLWNDPROC HOOK for this solution. and monitoring WM_ENDSESSION message. Thanks very much for your help. Carl

                  1 Reply Last reply
                  0
                  • A Antony M Kancidrowski

                    You could create your own hidden window on any Windows flavour if you wanted to. You could question why 'no windows' is a requirement. Perhaps it is only 'no visible windows'. Going with the stated requirement that 'no windows' are allowed. Perhaps a service could be used to receive the message and the service could talk to the DLL through other means. Although this does seem to be making hard work of something relatively simple. Ant. I'm hard, yet soft.
                    I'm coloured, yet clear.
                    I'm fruity and sweet.
                    I'm jelly, what am I? Muse on it further, I shall return!
                    - David Walliams (Little Britain)

                    A Offline
                    A Offline
                    AssemblySoft
                    wrote on last edited by
                    #9

                    Hi, please see latest reply to ALOK. Kind Regards Carl

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups