• Articles
  • Api Documentation
Show / Hide Table of Contents
  • Dapplo.Windows.App
    • AppQuery
  • Dapplo.Windows.Citrix
    • WinFrame
  • Dapplo.Windows.Citrix.Enums
    • ConnectStates
    • EventMask
    • InfoClasses
  • Dapplo.Windows.Citrix.Structs
    • ClientAddress
    • ClientDisplay
  • Dapplo.Windows.Clipboard
    • ClipboardMonitor
    • ClipboardNative
    • ClipboardUpdateInformation
    • StandardClipboardFormats
  • Dapplo.Windows.Com
    • ComProgIdAttribute
    • ComWrapper
    • DisposableCom
    • IDispatch
    • IDisposableCom<T>
    • IOleCommandTarget
    • IOleWindow
    • IUnknown
  • Dapplo.Windows.Common
    • Win32
    • WindowsVersion
  • Dapplo.Windows.Common.Enums
    • AdjacentTo
    • HResult
    • Win32Error
  • Dapplo.Windows.Common.Extensions
    • HResultExtensions
    • RectExensions
  • Dapplo.Windows.Common.Structs
    • POINT
    • RECT
    • RECTF
    • SIZE
  • Dapplo.Windows.Desktop
    • EnvironmentChangedEventArgs
    • EnvironmentMonitor
    • IInteropWindow
    • InteropWindow
    • InteropWindowExtensions
    • InteropWindowFactory
    • InteropWindowQuery
    • WindowScroller
    • WindowsEnumerator
    • WinEventHook
  • Dapplo.Windows.DesktopWindowsManager
    • Dwm
    • DwmBlurBehind
    • DwmBlurBehindFlags
    • DwmSetIconicLivePreviewFlags
    • DwmThumbnailProperties
    • DwmThumbnailPropertyFlags
    • DwmWindowAttributes
  • Dapplo.Windows.Dpi
    • BitmapScaleHandler
    • BitmapScaleHandler<TKey>
    • DpiAwareness
    • DpiAwarenessContext
    • DpiHandler
    • WinProcListener
  • Dapplo.Windows.Dpi.Enums
    • MonitorDpiType
  • Dapplo.Windows.Dpi.Forms
    • DpiAwareForm
    • FormsExtensions
  • Dapplo.Windows.Dpi.Wpf
    • WindowExtensions
  • Dapplo.Windows.Enums
    • InteropWindowCacheFlags
    • WinEventHookFlags
    • WinEvents
  • Dapplo.Windows.Gdi32
    • Gdi32Api
    • GdiExtensions
    • GdiPlusApi
  • Dapplo.Windows.Gdi32.Enums
    • BitmapCompressionMethods
    • ColorSpaceEnum
    • DeviceCaps
    • GdiPlusStatus
    • GpUnit
    • RasterOperations
  • Dapplo.Windows.Gdi32.SafeHandles
    • SafeCompatibleDcHandle
    • SafeDcHandle
    • SafeDeviceContextHandle
    • SafeDibSectionHandle
    • SafeHBitmapHandle
    • SafeObjectHandle
    • SafeRegionHandle
    • SafeSelectObjectHandle
    • SafeWindowDcHandle
  • Dapplo.Windows.Gdi32.Structs
    • BitfieldColorMask
    • BitmapFileHeader
    • BitmapInfoHeader
    • BlurParams
    • CieXyz
    • CieXyzTripple
  • Dapplo.Windows.Input
    • Hotkey
    • InputGenerator
    • KeyboardHook
    • KeyboardHookEventArgs
    • MouseHook
    • MouseHookEventArgs
  • Dapplo.Windows.Input.Enums
    • ExtendedKeyFlags
    • ExtendedMouseFlags
    • HookTypes
    • InputTypes
    • KeyEventFlags
    • MouseEventFlags
    • ScanCodes
    • VirtualKeyCodes
  • Dapplo.Windows.Input.Structs
    • HardwareInput
    • Input
    • InputUnion
    • KeyboardInput
    • KeyboardLowLevelHookStruct
    • MouseInput
    • MouseLowLevelHookStruct
  • Dapplo.Windows.Interop
    • DisposableCom
    • IDisposableCom<T>
  • Dapplo.Windows.Kernel32
    • Kernel32Api
    • PsApi
  • Dapplo.Windows.Kernel32.Enums
    • GlobalMemorySettings
    • ProcessAccessRights
    • ThreadAccess
    • WindowsProducts
    • WindowsProductTypes
    • WindowsSuites
  • Dapplo.Windows.Kernel32.Structs
    • OsVersionInfoEx
  • Dapplo.Windows.Messages
    • WindowsMessage
    • WindowsMessages
    • WinProcHandler
  • Dapplo.Windows.Multimedia
    • SoundSettings
    • SystemSounds
    • WinMm
  • Dapplo.Windows.Native
    • Shell32
    • Shell32.FolderType
    • Shell32.IconSize
  • Dapplo.Windows.Shell32
    • Shell32Api
  • Dapplo.Windows.Shell32.Enums
    • AppBarEdges
    • AppBarMessages
    • AppBarStates
  • Dapplo.Windows.Shell32.Structs
    • AppBarData
  • Dapplo.Windows.Structs
    • WinEventInfo
  • Dapplo.Windows.User32
    • User32Api
    • User32Api.EnumWindowsProc
  • Dapplo.Windows.User32.Enums
    • ClassLongIndex
    • CursorInfoFlags
    • DesktopAccessRight
    • ExtendedWindowStyleFlags
    • GetWindowCommands
    • MonitorFrom
    • MonitorInfoFlags
    • ObjectIdentifiers
    • ObjectStates
    • PrintWindowFlags
    • RegionResults
    • ScrollBarCommands
    • ScrollBarStateIndexes
    • ScrollBarTypes
    • ScrollInfoMask
    • ScrollModes
    • SendMessageTimeoutFlags
    • ShowWindowCommands
    • SysCommands
    • SystemMetric
    • SystemParametersInfoActions
    • SystemParametersInfoBehaviors
    • TitleBarInfoIndexes
    • WindowLongIndex
    • WindowPlacementFlags
    • WindowPos
    • WindowStyleFlags
  • Dapplo.Windows.User32.SafeHandles
    • SafeCurrentInputDesktopHandle
    • SafeIconHandle
  • Dapplo.Windows.User32.Structs
    • AnimationInfo
    • CursorInfo
    • DisplayInfo
    • IconInfo
    • MonitorInfoEx
    • ScrollBarInfo
    • ScrollInfo
    • TitleBarInfoEx
    • WindowInfo
    • WindowPlacement

Class Kernel32Api

Kernel 32 functionality

Inheritance
System.Object
Kernel32Api
Namespace: Dapplo.Windows.Kernel32
Assembly: Dapplo.Windows.Kernel32.dll
Syntax
public static class Kernel32Api : object

Fields

| Improve this Doc View Source

ATTACHCONSOLE_ATTACHPARENTPROCESS

default value if not specifing a process ID

Declaration
public const uint ATTACHCONSOLE_ATTACHPARENTPROCESS = null
Field Value
Type Description
System.UInt32

Methods

AllocConsole()

Allocates a new console for the calling process.

Declaration
public static bool AllocConsole()
Returns
Type Description
System.Boolean

AttachConsole(UInt32)

Attaches the calling process to the console of the specified process. See AllocConsole function

Declaration
public static bool AttachConsole(uint dwProcessId)
Parameters
Type Name Description
System.UInt32 dwProcessId

The identifier of the process whose console is to be used. Or -1 to use the console of the parent of the current process.

Returns
Type Description
System.Boolean

CloseHandle(IntPtr)

Closes an open object handle. See CloseHandle function The CloseHandle function closes handles to the following win32 objects:

  • Access token
  • Communications device
  • Console input
  • Console screen buffer
  • Event
  • File
  • File mapping
  • I/O completion port
  • Job
  • Mailslot
  • Memory resource notification
  • Mutex
  • Named pipe
  • Pipe
  • Process
  • Semaphore
  • Thread
  • Transaction
  • Waitable timer
Declaration
public static bool CloseHandle(IntPtr hObject)
Parameters
Type Name Description
IntPtr hObject

A valid handle to an open object.

Returns
Type Description
System.Boolean

true if it worked, use GetLastError if not

FreeLibrary(IntPtr)

Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. When the reference count reaches zero, the module is unloaded from the address space of the calling process and the handle is no longer valid. See FreeLibrary function

Declaration
public static bool FreeLibrary(IntPtr module)
Parameters
Type Name Description
IntPtr module

IntPtr

Returns
Type Description
System.Boolean

true if it worked, false if an error occured

GetModuleHandle(String)

Retrieves a module handle for the specified module. The module must have been loaded by the calling process. To avoid the race conditions described in the Remarks section, use the GetModuleHandleEx function. See GetModuleHandle function

Declaration
public static IntPtr GetModuleHandle(string lpModuleName)
Parameters
Type Name Description
System.String lpModuleName

The name of the loaded module (either a .dll or .exe file). If the file name extension is omitted, the default library extension .dll is appended. The file name string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to specify a path. When specifying a path, be sure to use backslashes (), not forward slashes (/). The name is compared (case independently) to the names of modules currently mapped into the address space of the calling process. If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file). The GetModuleHandle function does not retrieve handles for modules that were loaded using the LOAD_LIBRARY_AS_DATAFILE flag. For more information, see LoadLibraryEx.

Returns
Type Description
IntPtr

If the function succeeds, the return value is a handle to the specified module.

| Improve this Doc View Source

GetProcessPath(Int32)

Method to get the process path

Declaration
public static string GetProcessPath(int processid)
Parameters
Type Name Description
System.Int32 processid
Returns
Type Description
System.String

string

GetProductInfo(Int32, Int32, Int32, Int32, out WindowsProducts)

See GetProductInfo function

Declaration
public static bool GetProductInfo(int osMajorVersion, int osMinorVersion, int spMajorVersion, int spMinorVersion, out WindowsProducts edition)
Parameters
Type Name Description
System.Int32 osMajorVersion

The major version number of the operating system. The minimum value is 6. The combination of the dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, and dwSpMinorVersion parameters describes the maximum target operating system version for the application. For example, Windows Vista and Windows Server 2008 are version 6.0.0.0 and Windows 7 and Windows Server 2008 R2 are version 6.1.0.0.

System.Int32 osMinorVersion

The minor version number of the operating system. The minimum value is 0.

System.Int32 spMajorVersion

The major version number of the operating system service pack. The minimum value is 0.

System.Int32 spMinorVersion

The minor version number of the operating system service pack. The minimum value is 0.

WindowsProducts edition

WindowsProducts

Returns
Type Description
System.Boolean

GetVersionEx(ref OsVersionInfoEx)

See GetVersionEx function

Declaration
public static bool GetVersionEx(ref OsVersionInfoEx osVersionInfo)
Parameters
Type Name Description
OsVersionInfoEx osVersionInfo

OsVersionInfoEx

Returns
Type Description
System.Boolean

If the function fails, the return value is false. To get extended error information, call GetLastError.

GlobalAlloc(GlobalMemorySettings, UIntPtr)

Allocates the specified number of bytes from the heap. See GlobalAlloc function

Declaration
public static IntPtr GlobalAlloc(GlobalMemorySettings globalMemorySettings, UIntPtr bytes)
Parameters
Type Name Description
GlobalMemorySettings globalMemorySettings

The memory allocation attributes. If zero is specified, the default is GMEM_FIXED. This parameter can be one or more of the following values, except for the incompatible combinations that are specifically noted.

UIntPtr bytes

The number of bytes to allocate. If this parameter is zero and the uFlags parameter specifies GMEM_MOVEABLE, the function returns a handle to a memory object that is marked as discarded.

Returns
Type Description
IntPtr

If the function succeeds, the return value is a handle to the newly allocated memory object. If the function fails, the return value is NULL. To get extended error information, call GetLastError.

GlobalLock(IntPtr)

Locks a global memory object and returns a pointer to the first byte of the object's memory block.

Declaration
public static IntPtr GlobalLock(IntPtr hMem)
Parameters
Type Name Description
IntPtr hMem

IntPtr with a hGlobal, handle for a global memory blockk

Returns
Type Description
IntPtr

IntPtr to the first byte of the global memory block

GlobalSize(IntPtr)

Retrieves the current size of the specified global memory object, in bytes.

Declaration
public static int GlobalSize(IntPtr hMem)
Parameters
Type Name Description
IntPtr hMem

IntPtr with a hGlobal, handle for a global memory blockk

Returns
Type Description
System.Int32

int with the size

GlobalUnlock(IntPtr)

Decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE. This function has no effect on memory objects allocated with GMEM_FIXED. If the memory object is still locked after decrementing the lock count, the return value is a nonzero value. If the memory object is unlocked after decrementing the lock count, the function returns zero and GetLastError returns NO_ERROR. If the function fails, the return value is zero and GetLastError returns a value other than NO_ERROR.

Declaration
public static bool GlobalUnlock(IntPtr hMem)
Parameters
Type Name Description
IntPtr hMem

IntPtr with a hGlobal, handle for a global memory block

Returns
Type Description
System.Boolean

bool if the unlock worked.

LoadLibrary(String)

Loads the specified module into the address space of the calling process. The specified module may cause other modules to be loaded. See LoadLibrary function

Declaration
public static IntPtr LoadLibrary(string lpFileName)
Parameters
Type Name Description
System.String lpFileName

string with the library

Returns
Type Description
IntPtr

IntPtr for the module, IntPtr.Zero if this failed, use last error to see what went wrong

OpenProcess(ProcessAccessRights, Boolean, Int32)

Declaration
public static IntPtr OpenProcess(ProcessAccessRights dwDesiredAccess, bool bInheritHandle, int dwProcessId)
Parameters
Type Name Description
ProcessAccessRights dwDesiredAccess
System.Boolean bInheritHandle
System.Int32 dwProcessId
Returns
Type Description
IntPtr

QueryDosDevice(String, StringBuilder, UInt32)

Declaration
public static uint QueryDosDevice(string lpDeviceName, StringBuilder lpTargetPath, uint uuchMax)
Parameters
Type Name Description
System.String lpDeviceName
StringBuilder lpTargetPath
System.UInt32 uuchMax
Returns
Type Description
System.UInt32

QueryFullProcessImageName(IntPtr, UInt32, StringBuilder, ref UInt32)

Declaration
public static bool QueryFullProcessImageName(IntPtr hProcess, uint dwFlags, StringBuilder lpExeName, ref uint lpdwSize)
Parameters
Type Name Description
IntPtr hProcess
System.UInt32 dwFlags
StringBuilder lpExeName
System.UInt32 lpdwSize
Returns
Type Description
System.Boolean
  • Improve this Doc
  • View Source
Back to top Copyright © 2017 Dapplo