Cjwdev.WindowsAPI First Release Coming Soon

July 2, 2010 — Leave a comment

I have nearly finished the first release of my Windows API pack, which is a class library (DLL) that makes using certain Windows APIs from .NET code easier and simpler. You just add a reference to this class library and then you can call managed .NET methods from the library rather than having to figure out how to use the Windows APIs yourself. So far I have got just over 25 managed methods in this library, which makes use of roughly 45 Windows APIs. You can see a list of my managed methods and a description for each one below:

UPDATE: The first version is now available and can be found here.

 

RefreshDevices – Causes the OS to refresh its list of connected devices, equivalent to doing "scan for hardware changes" in device manager
GetFreeDiskSpace – Returns the amount of space free on a remote disk, specified via UNC path
GetParentProcess – returns the process that started the specified process (aka the parent process)
MapNetworkDrive – creates a network drive mapped to the specified UNC path
RemoveNetworkDrive – deletes an existing mapped network drive
GetUncPathFromNetworkDrive – Returns the UNC path that the specified network drive is mapped to
DoesNativeMethodExist – Determines whether or not a specified method exists in an unmanaged DLL
ShareExistingFolder – shares a folder and assigns the specified share permissions
Is64BitOperatingSystem (property) – Returns true if the OS is 64 bit, even if the process calling this property is running in 32 bit emulation mode.
GetAllIcons – Returns a List(Of Icon) containing all of the icons in the specified dll, exe or ico file
GetIconAtIndex – Returns the icon at the specified index in the specified dll, exe or ico file
GetTopLevelWindows – Returns a list of all visible windows with their handle, class name, title bar text, owning process, and window icon
GetChildWindows – Returns a list of all child windows of a specified window, in the same format as GetTopLevelWindows
IsWow64Process – determines whether or not the specified process is a 32 bit process running on a 64 bit OS
ReleaseIpAddresses – releases all IPv4 addresses that were acquired via DHCP
RenewIpAddresses – renews the DHCP lease for all IPv4 addresses that were acquired via DHCP
JoinToDomain – Joins the computer to the specified domain
RemoveFromDomain – Removes the computer from the domain it is joined to (can also be run against a remote computer)
GetStringResource – gets a string from a DLL resource address (e.g @%Systemroot%\system32\wbem\wmisvc.dll,-203)
ReadMemory – reads a specified amount of bytes from a process’s virtual memory
GetCommandLineArgs – gets the command line arguments that were passed to any currently running process when it was started (even if it was not started by your program)
GetServices – gets a list of all services that are in the specified state (running, stopped etc) with their process IDs
GetServicesFromProcess – pass in a process and get back a list of any services that are running in that process
FlashWindow – Causes the specified window to flash to get the user’s attention
SetWindowState – Make a specified window hide, minimize, maximize, etc
InstallService – Creates a Windows Service with the specified parameters on the local machine or a remote machine
DeleteService – Removes the specified Windows Service from the local machine or a remote machine

I had planned to include quite a few more before releasing the first version but as a few people have already showed an interest in using it, I figured it would be better to release it soon instead of spending another few weeks on it. I can always add more to the next version.

Anyway, this first release should be ready within the next 7 days – I’ll post a download link in a new blog post when it is available. In the mean time, if you have any suggestions for APIs you would like to see a managed version of in the next version then let me know.

Chris

 

Oh and there will also be a class in this class library where all of the Windows APIs are actually defined (i.e. using DllImport) and each of these definitions are Public so that if you want to use one of the APIs directly then you can do so without needing to look up the correct declaration yourself. There are also a few APIs in this class that I have not had chance to create managed methods for yet, such as RegisterHotKey, but anyway here is the list of APIs that will be included in this first release:

GetFreeDiskSpaceEx
WNetCancelConnection
WNetAddConnection2
NetShareAdd
InitializeSecurityDescriptor
SetEntriesInAcl
SetSecurityDescriptorDacl
IsValidSecurityDescriptor
SystemParametersInfo
NetShareAdd
WNetGetConnection
GetProfileType
GetForegroundWindow
ShowWindow
RegisterHotKey
UnregisterHotKey
CM_Reenumerate_DevNode
NtQueryInformationProcess
ExtractIconEx
DestroyIcon
DoesWin32MethodExist
IsWow64Process
GetModuleHandle
GetProcAddress
EnumWindows
EnumChildWindows
GetWindowTextLength
GetWindowText
IsWindowVisible
GetWindowThreadProcessID
GetClassName
SetParent
SendMessage
GetWindowLong
GetClassLong
IpReleaseAddress
IpRenewAddress
GetInterfaceInfo
NetJoinDomain
NetUnjoinDomain
LoadLibrary
FreeLibrary
LoadString
CloseHandle
OpenProcess
ReadProcessMemory
CreateProcess
CreatePipe
PeekNamedPipe
WaitForMultipleObjects
ReadFile
WriteFile
DuplicateHandle
FlashWindowEx
OpenSCManager
EnumServicesStatusEx
CloseServiceHandle
CreateService
DeleteService
OpenService
StartService

No Comments

Be the first to start the conversation!

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