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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help to develop a service to get UPS information by unmanaged C++ code in Win7

Help to develop a service to get UPS information by unmanaged C++ code in Win7

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++comhelp
5 Posts 4 Posters 2 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.
  • N Offline
    N Offline
    ndkit
    wrote on last edited by
    #1

    Dear all, I want to develop a service (that is written by unmanaged C++) in Win7. This service can detect status of UPS, example: low battery, out of electric, etc.. It connect with UPS by RS232C cable through COM port. I google and find some funtions: GetCommState, SetCommState, GetCommModemStatus but don't know how to use it to check status of UPS (low battery, out of electric, ...) Pls. help me to solve it :( . Thanks a lot. Ratkit!

    G D R 3 Replies Last reply
    0
    • N ndkit

      Dear all, I want to develop a service (that is written by unmanaged C++) in Win7. This service can detect status of UPS, example: low battery, out of electric, etc.. It connect with UPS by RS232C cable through COM port. I google and find some funtions: GetCommState, SetCommState, GetCommModemStatus but don't know how to use it to check status of UPS (low battery, out of electric, ...) Pls. help me to solve it :( . Thanks a lot. Ratkit!

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      You havnt said what you want to DO with the UPS status once you've found it - lets assume you wish to write it to the Windows Event Log for start.. I would appoach it in a number of 'phases', not knowing what experience you have 1) build a console mode program capable of writing application events to the event log 2) use something like Serial library for C++[^] in a console mode program to be able to read the UPS data from the serial port - somewhere in the specs for the UPS it will tell you how to interpret the data to give you the status 3) then write a service, make sure you can do the normal things - start, stop, use the knowledge gained from (1) to write an event to the log on a timed basis - eg, every 5 minutes 4) once youve gotten here, you then re-do the service to use the knowledge gained in step 2, to determine and log the UPS status to the event log Once your service is up and running, you can expand the logging event to (for example) send an email if the UPS needs attention, or (for example) add a system-tray applet and change the colour of it to red 'g'

      1 Reply Last reply
      0
      • N ndkit

        Dear all, I want to develop a service (that is written by unmanaged C++) in Win7. This service can detect status of UPS, example: low battery, out of electric, etc.. It connect with UPS by RS232C cable through COM port. I google and find some funtions: GetCommState, SetCommState, GetCommModemStatus but don't know how to use it to check status of UPS (low battery, out of electric, ...) Pls. help me to solve it :( . Thanks a lot. Ratkit!

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

        Check out the Win32_UninterruptiblePowerSupply WMI class.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Man who follows car will be exhausted." - Confucius

        N 1 Reply Last reply
        0
        • N ndkit

          Dear all, I want to develop a service (that is written by unmanaged C++) in Win7. This service can detect status of UPS, example: low battery, out of electric, etc.. It connect with UPS by RS232C cable through COM port. I google and find some funtions: GetCommState, SetCommState, GetCommModemStatus but don't know how to use it to check status of UPS (low battery, out of electric, ...) Pls. help me to solve it :( . Thanks a lot. Ratkit!

          R Offline
          R Offline
          Rick York
          wrote on last edited by
          #4

          In addition to what David said, you can call GetSystemPowerStatus() to get that information.

          1 Reply Last reply
          0
          • D David Crow

            Check out the Win32_UninterruptiblePowerSupply WMI class.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Man who follows car will be exhausted." - Confucius

            N Offline
            N Offline
            ndkit
            wrote on last edited by
            #5

            According to the documentation on Win32_UninterruptiblePowerSupply: "Beginning with Windows Vista, this class is obsolete and not available because the UPS service is no longer available." http://msdn.microsoft.com/en-us/library/aa394503(VS.85).aspx Can you suggest another way to help me solve it?

            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