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. System Information

System Information

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
7 Posts 6 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.
  • D Offline
    D Offline
    Daniel Kanev
    wrote on last edited by
    #1

    Hi, I want to write a console application with WinMain, i.e. WIN32 APP but without any windows. I want it to have a while cycle in the main func doing something and the program to exit gracefully when Windows shuts down. And my problem is I do not know how to get system information - if windows is shutting down or restarting. If I do not exit the cycle the system will hang waiting for my program to finish. And as I do not want to run it as a service there is no way to catch the messages coming from the OS because they are sent either to services or Windows Apps. Can you help me ?

    M D D J 4 Replies Last reply
    0
    • D Daniel Kanev

      Hi, I want to write a console application with WinMain, i.e. WIN32 APP but without any windows. I want it to have a while cycle in the main func doing something and the program to exit gracefully when Windows shuts down. And my problem is I do not know how to get system information - if windows is shutting down or restarting. If I do not exit the cycle the system will hang waiting for my program to finish. And as I do not want to run it as a service there is no way to catch the messages coming from the OS because they are sent either to services or Windows Apps. Can you help me ?

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      You could try creating one Window but make it invisible. Not pretty but even Microsoft themselves have been known to resort to this at times. I'm sure WMI could also be used to get you the information you want but I don't knw any more about it than that I'm afraid.

      Nothing is exactly what it seems but everything with seems can be unpicked.

      1 Reply Last reply
      0
      • D Daniel Kanev

        Hi, I want to write a console application with WinMain, i.e. WIN32 APP but without any windows. I want it to have a while cycle in the main func doing something and the program to exit gracefully when Windows shuts down. And my problem is I do not know how to get system information - if windows is shutting down or restarting. If I do not exit the cycle the system will hang waiting for my program to finish. And as I do not want to run it as a service there is no way to catch the messages coming from the OS because they are sent either to services or Windows Apps. Can you help me ?

        D Offline
        D Offline
        Don Box
        wrote on last edited by
        #3

        U could handle WM_ENDSESSION.

        Come online at:- jubinc@skype

        1 Reply Last reply
        0
        • D Daniel Kanev

          Hi, I want to write a console application with WinMain, i.e. WIN32 APP but without any windows. I want it to have a while cycle in the main func doing something and the program to exit gracefully when Windows shuts down. And my problem is I do not know how to get system information - if windows is shutting down or restarting. If I do not exit the cycle the system will hang waiting for my program to finish. And as I do not want to run it as a service there is no way to catch the messages coming from the OS because they are sent either to services or Windows Apps. Can you help me ?

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Without a window, how are you going to respond to the WM_QUERYENDSESSION or WM_ENDSESSION message?

          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          S 1 Reply Last reply
          0
          • D Daniel Kanev

            Hi, I want to write a console application with WinMain, i.e. WIN32 APP but without any windows. I want it to have a while cycle in the main func doing something and the program to exit gracefully when Windows shuts down. And my problem is I do not know how to get system information - if windows is shutting down or restarting. If I do not exit the cycle the system will hang waiting for my program to finish. And as I do not want to run it as a service there is no way to catch the messages coming from the OS because they are sent either to services or Windows Apps. Can you help me ?

            J Offline
            J Offline
            jhwurmbach
            wrote on last edited by
            #5

            Have your application be a window - hidden and with no size. This way, you can catch the relevant messages.

            Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
            Douglas Adams, "Dirk Gently's Holistic Detective Agency"

            1 Reply Last reply
            0
            • D David Crow

              Without a window, how are you going to respond to the WM_QUERYENDSESSION or WM_ENDSESSION message?

              "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              You have a hidden window. It's a common technique. If you use Spy you'll find a number of such windows.

              Steve

              D 1 Reply Last reply
              0
              • S Stephen Hewitt

                You have a hidden window. It's a common technique. If you use Spy you'll find a number of such windows.

                Steve

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                I know that, but Daniel's requirement was, "without any windows."

                "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                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