Cjwdev.WindowsAPI Update

July 9, 2010 — 1 Comment

Even though I only released my .NET Windows API library (Cjwdev.WindowsAPI) quite recently, I’m planning to release a new version pretty soon as there are still plenty of things I want to add to it. EDIT: New version is now available, see this post. I will be releasing updated versions fairly often rather than waiting until I have a large amount of new methods etc, so keep checking back on this blog for updates. This post describes the new methods and classes that I have added (or am planning to add) to the next release, along with the Windows APIs that the managed methods use. As always, let me know if there are any particular APIs you would like to see in here and I will try and get them in.

One of the main new features in this version will be the inclusion of some power management methods, held in a class named NativePowerScheme. So if you have ever wanted to manage or query windows power settings from your .NET app then this should help you out – in this version there may only be some basic power scheme methods but in future versions this will hopefully be expanded to include methods that let you completely customise the power settings, with the ability to create new power schemes and edit existing power configuration. Also, these power management methods will be compatible with Windows XP as well as Vista and Windows 7.

Anyway, here are the new methods – check back on this blog soon for the new version:

NativePowerScheme.GetAvailablePowerSchemes
Gets a list of all power schemes, with basic information such as the name, description and index

NativePowerScheme.GetActivePowerScheme
Gets the currently active power scheme

NativePowerScheme.SetActivePowerScheme
Sets which power scheme is active

NativeOperatingSystem.RenameComputer
Renames the local computer to the specified new name. If the computer is part of a domain then the domain account for the computer is renamed as well

NativeOperatingSystem.DeleteUserProfile
Deletes a user’s profile and all user related settings

NativeOperatingSystem.UserProfilesDirectory (property)
Returns the root directory path where all user profiles are stored (I dont think there is an environmental variable for this but if anyone knows of one then let me know and I wont bother including this)

NativeFileSystem.EmptyRecycleBin
Empties the recycle bin

NativeFileSystem.GetRecycleBinItemCount
Returns the number of items in the recycle bin

NativeFileSystem.GetRecycleBinItemSize
Returns the total size (in bytes) of the items in the recycle bin

NativeWindow.GetWindowFromTitle
Finds a window that has the specified title and creates a NativeWindow instance from it (which includes the title, handle, owning process and window icon)

NativeWindow.GetWindowFromPartialTitle
Returns a list of all windows that have a title that contains the specified string – useful if you dont know the entire title of the window

NativeWindow.MakeTopMost
Makes the specified window a "topmost" window so that it always appears on top of all other windows

NativeWindow.GetActiveWindow
Gets the window that currently has focus and creates a NativeWindow instance from it (so includes window title, owning process, handle etc)

NativeNetwork.ReleaseIPAddresses
Releases all v4 IP addresses that were acquired via DHCP

NativeNetwork.RenewIPAddresses
Renews all v4 IP addresses that were acquired via DHCP

 

Here are some of the Windows APIs that these new methods use (which are all available in the ApiDefinitions class in my DLL if you ever need to use them directly) :

SHQueryRecycleBin

SHEmptyRecycleBin

GetProfilesDirectory

EnumPwrSchemes

GetActivePwrScheme

SetActivePwrScheme

FindWindow

IpReleaseAddress

IpRenewAddress

GetInterfaceInfo

NetRenameMachineInDomain

SetWindowPos

DeleteProfile

SetComputerNameEx

Trackbacks and Pingbacks:

  1. Cjwdev.WindowsAPI API Pack Released « Cjwdev - July 19, 2010

    […] See this post for an idea of what to expect in the next […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s