[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

where is the sysinfo counterpart in .NET?

Posted on 2004-04-15
6
Medium Priority
?
405 Views
Last Modified: 2007-12-19
I am new to .NET and am attempting to upgrade a VB6 application that tracks whether or not a laptop is on battery power or oputlet power.

The upgrade wizard simply wrapped the sysinfo control - Interop.SysInfoLib and AxInterop.SysInfoLib

I found the PowerStatusChange event in .NET but have had no luck finding the properties:
ACStatus
BatteryLifePercent
BatterFullTime
BatteryLifeTime
BatteryStatus

0
Comment
Question by:take_the_train
[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
  • 2
6 Comments
 
LVL 41

Expert Comment

by:graye
ID: 10836278
I'd recommend the use of Windows Management Instrumentation (WMI)...  it'd go something like this:

' remember to also add System.Management as a reference
Imports System.Management

Dim wmi As ManagementClass
Dim objs As ManagementObjectCollection
Dim obj As ManagementObject

wmi = New ManagementClass("Win32_Battery")
objs = wmi.GetInstances()
For Each obj In objs
      msgbox(Convert.ToInt32(obj.EstimatedRunTime))
      msgbox(Convert.ToInt32(obj.BatteryStatus))
       etc...
Next
objs.Dispose()
wmi.Dispose()
0
 

Author Comment

by:take_the_train
ID: 10838572
'EstimatedRunTime' is not a member of 'System.Management.ManagementObject'.
'BatteryStatus' is not a member of 'System.Management.ManagementObject'.

Sorry if I am dense but I received the following two build errors and could not find these properties in the system management object.
0
 

Expert Comment

by:CheewaCheewa
ID: 10838695
look into learning how to use
Import Microsoft.Win32.RegistryKey
Get the values you need there as far
as settings and such.

Start Regedit in the run box
and look at
HKEY_CURRENT_USER\Control Panel\PowerCfg

Hope it helps
0
 
LVL 41

Accepted Solution

by:
graye earned 1000 total points
ID: 10841429
oops, you're right... I was mixing the syntax used with VBScript.   Sorry about that.

the proper syntax for VB.Net is:

        obj("EstimatedRunTime")

Besides, I was kinda hoping you'd be looking at the Win32_Battery documentation, so you'd see all of the other objects that were out there... I only listed two.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

656 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