where is the sysinfo counterpart in .NET?

Posted on 2004-04-15
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:

Question by:take_the_train
  • 2
LVL 41

Expert Comment

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

Author Comment

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.

Expert Comment

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
LVL 41

Accepted Solution

graye earned 250 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:


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.

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now