Win32 Programming Notes
Thanks for stopping by! I hope to find out how the Windows system works.
Windows is an operating system product of Microsoft Corporation. It is in wide use as the operating system for IBM compatible personal computers.
To program Windows and Win32 programs is to know how to apply Microsoft's practices to programming.
First you will need a compiler. You can buy one at the store or online. We chose DJGPP, a freeware
DOS compiler with Gnu C and C++ facility. To access Win32 functions, also used is the RSXNTDJ
library linker and libraries for Win32 programming. Finally, we aquired the MS Platform SDK
released recently, which has all the libs and header files for Win32 APIs. Recommended is Microsoft Visual C++ 5.0 and MSDN, for obvious reasons. Other good compilers are PowerBuilder and Optima++.
Here are some terms used in this document:
- pointer pointer to memory location
- handle handle of memory location
- struct group of fields
- object oriented object oriented
Here is notation format:
- notes: regular font
- code: monospace font
Types
There are a number of different data types used in Win32 programming. The regular C types are
used, for example character, integer, Boolean, pointer, and handle.
The following tables are taken from this page:
Simple Types, http://premium.microsoft.com/msdn/library/sdkdoc/type_6uk5.htm. Note: this page has changed in the last month or so.
Here is a list of Windows primitives and types that are used:
- BOOL - true or false
- BOOLEAN - same as bool
- BYTE - 8 bits
- CHAR - Windows character
- DWORD - 32 bit unsigned integer
- DWORDLONG - 64 bit unsigned integer
- FLOAT - floating point value
- INT - signed integer
- LONG - 32 bit signed integer
- LONGLONG - 64 bit signed integer
- SHORT - short integer
- UCHAR - unsigned Windows character
- UINT - unsigned integer
- ULONG - unsigned long integer
- USHORT - unsigned short integer
- WORD - 16 bit unsigned integer
These pointer types to primitives and Strings and constants are used:
- PBOOL a Boolean
- PBOOLEAN a Boolean
- PBYTE a BYTE
- PCHAR a CHAR
- PCSTR a constant null-terminated Windows character string
- PCWCH a constant Unicode character
- PCWSTR a constant null-terminated Unicode character string
- PDWORD a DWORD
- PFLOAT a FLOAT
- PINT an INT
- PLONG a LONG
- PSHORT a SHORT
- PSTR a null-terminated Windows character string
- PTBYTE a Windows or Unicode character
- PTCHAR a Windows or Unicode character
- PTSTR
- PUCHAR
- PUINT
- PULONG
- PUSHORT
- PWCHAR
- PWSTR
- LPCSTR constant null-terminated Windows character string
- LPCTSTR constant null-terminated Unicode or Windows character string
- LPCVOID a constant
- LPDWORD a DWORD
- LPSTR a null-terminated Windows character string
- LPSTREAM a stream
- LPVOID void
- LPWORD a WORD
- LPWSTR a null-terminated Unicode character string
These are pointers to library defined functions:
- APPLET_PROC called to init control panel
These pointers to application defined callback functions are used:
- ABORTPROC - callback when print job is to be cancelled during spooling
- ACMDRIVERENUMCB - callback used with acmDriverEnum
- ACMDRIVERPROC - audio compression manager (ACM) callback
- ACMFILTERCHOOSEHOOKPROC - dialog procedure for use with ACM
- ACMFILTERENUMCB - callback used with acmFilterEnum
- ACMFILTERTAGENUMCB - callback used with acmFilterTagenum
- ACMFORMATCHOOSEHOOKPROC -callback used with acmFilterChoose
- ACMFORMATENUMCB - callback used with acmFormatEnum
- ACMFORMATTAGENUMCB - callback used with acmFormatTagEnum
- CALINFO_ENUMPROC - callback to receive calendar information string with EnumCalendarInfoProc
- DATEFMT_ENUMPROC - callback to receive date format string with EnumDateFormats
- DESKTOPENUMPROC - callback to receive desktop name used with EnumDesktops
- DLGPROC - callback from dialog, used with DialogBox
- DRAWSTATEPROC - callback to render image for DrawState
- EDITWORDBREAKPROC - callback when editor breaks a line of text used with EditWordBreakProc
- ENHMFENUMPROC - enumerates enhanced metafile records with EnhMetaFileProc
- ENUMRESLANGPROC - enumerates resource language with EnumResLangProc
- ENUMRESNAMEPROC - enumerates resource names with EnumResNameProc
- ENUMRESTYPEPROC - enumerates resource types with EnumResTypeProc
- FONTENUMPROC - enumerates fonts with EnumFontFamExProc
- GOBJENUMPROC - enumerates GDI objects with EnumObjectsProc
- GRAYSTRINGPROC draws gray text with OutputProc
- HOOKPROC callback to SetWindowsHookEx
- LOCALE_ENUMPROC receives locale identifier string with EnumLocalesProc
- LPCCHOOKPROC hook callback for Color dialog with CCHookProc
- LPCFHOOKPROC hook callback for Font dialog with CFHookProc
- LPFRHOOKPROC hook callback for Find and Replace with FRHookProc
- LPOFNHOOKPROC hook callback for Open and Save As with OFNProcHook
- LPPAGEPAINTHOOK hook callback for Page Setup with PagePaintHook
- LPPAGESETUPHOOK hook callback for Page Setup for PageSetupHook
- LPPRINTHOOKPROC hook callback for Page Setup for PrintHookProc
- LPPROGRESS_ROUTINE callback for copy progress routine with CopyProgressRoutine.
- LPSETUPHOOKPROC hook callback for Print Setup with SetupHookProc
- PFNCALLBACK - pointer to callback function that processes DDE transactions
- PROPENUMPROC enumerates windows properties with PropEnumProc
- PROPENUMPROCEX enumerates windows properties with PropEnumProcEx
- REGISTERWORDENUMPROC processes register strings with EnumRegisterWordProc
- SENDASYNCPROC callback with SendAsyncProc and SendMessageCallback
- TIMEFMT_ENUMPROC callback to receive time format string with EnumTimeFromatsProc
- TIMERPROC callback with TimerProc
- WINSTAENUMPROC receives windows station name, with EnumWindowStationProc
- WNDENUMPROC enumerates windows with EnumChildProc, EnumThreadWndProc, EnumWindowsProc
- WNDPROC used with WindowProc
Here are handles that are used as data types copied from source with added links:
- HACCEL accelerator table
- HANDLE object
- HBITMAP bitmap
- HBRUSH brush
- HCOLORSPACE logical color space
- HCONV DDE conversation
- HCONVLIST DDE conversation list
- HCURSOR cursor
- HDC device context
- HDDEDATA DDE data
- HDESK desktop
- HDROP internal drop structure
- HDWP handle to deferred window position structure
- HENHMETAFILE handle to enhanced metafile
- HFILE handle to file created from OpenFile, not CreateFile
- HFONT font
- HGDIOBJ GDI object
- HGLOBAL global memory block
- HHOOK hook
- HICON icon
- HIMAGELIST image list
- HIMC image context
- HINSTANCE instance
- HKEY registry key
- HKL keyboard layout
- HLOCAL local memory block
- HMENU menu
- HMETAFILE metafile
- HMODULE module
- HPALETTE palette
- HPEN pen
- HRGN region
- HRSRC resource
- HSZ zero terminated string
- HTREEITEM tree item
- HWINSTA window station
- HWND window
- SC_HANDLE service control mamager database
- SC_LOCK service control manager database lock
- SERVICE_STATUS_HANDLE service status value
These types and structs are from the Win APi
- ATOM - a character string in memory table
- CALID - a calendar type with EnumCalendarInfo
- CALTYPE - calendar type information
- CALLBACK - calling convention for callback functions
- COLORREF - 32 RGB value, 0x00BBGGRR
- FARPROC - pointer to a callback function
- FILE_SEGMENT_ELEMENT - pointer to a buffer
- IPADDR - IP address
- LANGID - language identifier
- LCID - local identifier, locale
- LCSCSTYPE - color space object
- LCSGAMUTMATCH gamut-matching method
- LCTYPE - locale type
- LINEDDAPROC - pointer to callback that processes line coordinates
- LOGPALETTE - logical color palette
- LOGPEN - with CreatePenIndirect
- LOGBRUSH - style, color, and pattern of logical brush with CreateBrushIndirect and ExtCreatePen
- LPFIBER_START_ROUTINE - pointer to a fiber function
- LPHANDLER_FUNCTION - pointer to a control handler for Win32 service
- LPTHREAD_START_ROUTINE - pointer to a thread function
- LUID - locally unique identifier
- PALETTEENTRY - color and usage of entry in logical color palette
- PHANDLER_ROUTINE - pointer to a console control handler machine
- PHKEY - pointer to registry key
- PLUID - pointer to a locally unique identifier
- PTIMERAPCROUTINE - pointer to a timer completion routine with TimerACPProc
- REGSAM - security access mask for registry key
- WNDPROC - pointer to application-defined window procedure
- WINAPI - Win32 api function calls
Here are the newer ones on that page found more recently plus some LP types above.
- LPCRITICAL_SECTION pointer to a critical-section object
- PCRITICAL_SECTION pointer to a critical-section object
- LRESULT signed result of message processing
- WPARAM 32 bit message parameter
- YIELDPROC yield callback with mciSetYieldProc
API Notes and Overview
The hardware is run from VXDs which are loadable device drivers.
Throughout the API a number of functions have identically named classes appended with Ex, like
CreateWindowEx. These functions generally have most or all have all of the features of the original
function plus enhancements. These functions are not present for all platforms mostly NT 3.51 and WFW 3.11, but should be
available in future platforms.
Writing an Application
At it's most basic, a Windows application is defined by a simple C program with a method WinMain.
The WinMain method is called when this program compiled to an EXE is executed through MS's
windowing shell.
#include "windows.h"
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)(
)
The WINAPI macro is expanded by the compiler. The HINSTANCE is a handle to a Window instance.
hPrevInstance is not used and is generally null. The lpCmdLine
is a pointer to the first string of the command line.
Within the body of the WinMain method, register the main Window of the application and start message queue.
The message queue is used by the operating system to deliver user and system events to the Window component
registered in this step.
As variables within the method, have the window definition struct, a message, and a handle to the window when created.
MSG message
WNDCLASSEX wc
HWND hWindow
First, register the Window with a filled in example of the Windows definition struct, wc.
wc.lpszClassName="GenericAppClass";
wc.lpfnWndProc=MainWndProc;
wc.style= CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon=LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName="GenericAppMenu";
wc.cbClsExtra=0;
wc.cbWndExtra=0;
Then use the RegisterClass method to create a new Window based on the struct.
RegisterClass( &wc);
Then, use the CreateWindow method to show the window.
hWnd = CreateWindow(
"GenericAppClass", // LPCTSTR lpClassName - pointer to registered class name
"Testing damn application", // LPCTSTR lpwindowName - pointer to window name
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL, // DWORD dwStyle - window style
0, // int x - horizontal position of window
0, // int y - vertical position of window
CW_USEDEFAULT, // int nWidth - window width
CW_USEDEFAULT, // int nHeight - window height
NULL, // HWND hWndParent - handle to parent or owner window
NULL, // HMENU hMenu - handle to menu or child-window identifier
hInstance, // HANDLE hInstance handle to application instance
NULL // LPVOID lpParam - pointer to window-creation data
);
Alternatively, use the CreateWindowEx function.
The CreateWindowEx function has another argument to the method, DWORD dwExStyle. This allows
the window to use extended styles which includes such things as enabling drag and drop technology and various other things.
Once a window is created, then use the ShowWindow function to display the window on the screen.
ShowWindow(
hWnd // HWND hwnd - the window to be shown
nCmdShow // int - window display parameter
);
The nCmdShow argument specifies window display parameter, but there are some caveats. If the EXE was called from another
program with a STARTINFO struct, the first time the application calls the ShowWindow method the nCmdShow will be the
one specified in the STARTINFO struct. Otherwise, the conventional way is to use the nCmdShow variable provided in the WinMain function, that is
the execution environment passes the window display flag. After that the different parameters for nCmdShow can be used.
Register the Windows program to start the application.
Windows
The Window Class has these functions, from http://premium.microsoft.com/msdn/library/sdkdoc/winclass_0n5f.htm. The Windows class has a variety of parameters, viz http://premium.microsoft.com/msdn/library/sdkdoc/winclass_1qcz.htm.
BOOL GetClassInfoEx(
HINSTANCE hInstance,
LPCTSTR lpszClass,
LPWNDCLASSEX lpwcx
);
DWORD GetClassLong(
HWND hWnd,
int nIndex
);
int GetClassName(
HWND hWnd,
LPSTR lpClassName,
int nMaxCount
);
LONG GetWindowLong(
HWND hWnd,
int nIndex
);
ATOM RegisterClassEx(
CONST WNDCLASSEX *lpwcx
);
DWORD SetClassLong{
HWND hWnd,
int nIndex,
LONG dwNewLong
);
LONG SetWindowLong(
HWND hWnd,
int nIndex,
LONG dwNewLong
);
BOOL UnregisterClass(
lpClassName,
HINSTNACE hInstance
);
There are many more parameters you can apply to Windows Message handling.
The WNDCLASSEX structure (http://premium.microsoft.com/msdn/library/sdkdoc/winclass_450y.htm) is used when creating windows using the CreateWindow or CreateWindowEx function.
typedef struct _WNDCLASSEX{
UINT cbSize;
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hBrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
HICON hIconSm;
} WNDCLASSEX;
These function are used with Windows, from this page: http://premium.microsoft.com/msdn/library/sdkdoc/windows_8qyb.htm:
BOOL AdjustWindowRect(
LPRECT lpRect,
DWORD dwStyle,
BOOL bMenu
);
BOOL AdjustWidowRectEx(
LPRECT lpRect,
DWORD dwStyle,
BOOL bMenu,
DWORD dwExStyle
);
BOOL AnimateWindow(
HWND hWnd,
DWORD dwTime,
DWORD dwFlags
);
UINT ArrangeIconicWindows(
HWND hWnd
);
HDWP BeginDeferWindowPos(
int nNumWindows
)
BOOL BringWindowToTop(
HWND hWnd
)
WORD WINAPI CascadeWindows(
HWND hWndParent.
UINT wHow,
CONST RECT *lpRect,
UINT cKids,
const HWND FAR *lpKids
);
HWND ChildWindowFromPoint(
HWND hWndParent,
POINT point
);
HWND ChildWindowFromPointEx(
HWND hWndParent,
POINT point,
UINT uFlags
);
BOOL CloseWindow(
HWND hWnd
);
HWND CreateWindow(
LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HANDLE hInstance,
LPVOID lpParam
);
HWND CreateWindowEx(
DWORD dwExStyle,
LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);
HDWP DeferWindowPos(
HDWP hWinPosInfo,
HWND hWnd,
HWND hWndInsertAfter,
int x,
int y,
int cx,
int cy,
UINT uFlags
);
BOOL DestroyWindow(
HWND hWnd
);
BOOL EnableWindow(
HWND hWnd,
BOOL bEnable
);
BOOL CALLBACK EnumChildProc(
HWND hWnd,
LPARAM lParam
);
BOOL EnumChildWindows(
HWND hWndParent,
WNDENUMPROC lpEnumProc,
LPARAM lParam
);
BOOL EnumThreadWindows(
DWORD dwThreadId,
WNDENUMPROC lpfn,
LPARAM
(;
BOOL CALLBACK EnumThreadWndProc(
HWND hWnd,
LPARAM lParam
);
BOOL EnumWindows(
WNDENUMPROC lpEnumFunc,
LPARAM lParam
);
BOOL CALLBACK EnumWindowsProc(
HWND hWnd,
LPARAM lParam
);
HWND FindWindow(
LPCTSTR lpClassName,
LPCTSTR lpWindowName
);
HWND FindWindowEx(
HWND hWndParent,
HWND hWndChildAfter,
LPCTSTR lpszClass,
LPCTSTR lpszWindow
);
BOOL GetClientRect(
HWND hWnd,
LPRECT lpRect
);
HWND GetDesktopWindow(VOID);
HWND GetForegroundWindow(VOID);
HWND GetLastActivePopup(
HWND hWnd
);
HWND GetNextWindow(
HWND hWnd,
UINT wCmd
);
HWND GetParent(
HWND hWnd
);
HWND GetTopWindow(
HWND hWnd
);
HWND GetWindow(
HWND hWnd,
UINT uCmd
);
BOOL GetWindowPlacement(
HWND hWnd,
WINDOWPLACEMNT * lpwndpl
);
BOOL GetWindowRect(
HWND hWnd,
LPRECT lpRect
);
int GetWindowText(
HWND hWnd,
LPTSTR lpString,
int nMaxCount
);
int GetWindowTextLength(
HWND hWnd
);
DWORD GetWindowThreadProcessId(
HWND hWnd,
LPDWORD lpdwProcessId
);
BOOL IsChild(
HWND hWndParent,
HWND hWnd
);
BOOL IsIconic(
HWND hWnd
);
BOOL IsWindow(
HWND hWnd
);
BOOL IsWindowUnicode(
HWND hWnd
);
BOOL IsWindowVisible(
HWND hWnd
);
BOOL IsZoomed(
HWND hWnd
);
BOOL MoveWindow(
HWND hWnd,
int x,
int y,
int nWidth,
int nHeight,
BOOL bRepaint
);
BOOL OpenIcon(
HWND hWnd
);
BOOL SetForegroundWindow(
HWND hWnd
);
HWND SetParent(
HWND hWndChild,
HWND hWndNewParent
);
LONG SetWindowLong(
HWND hWnd,
int nIndex,
LONG dwNewLong
);
BOOL SetWindowPlacement(
HWND hWnd,
CONST WINDOWPLACEMENT *lpwndpl
);
BOOL SetWindowPos(
HWND hWnd,
HWND hWndInsertAfter,
int x,
int y,
int cx,
int cy,
UINT uFlags
);
BOOL SetWindowText(
HWND hWnd,
LPCTSTR lpString
);
BOOL ShowOwnedPopups(
HWND hWnd,
BOOL fShow
);
BOOL ShowWindow(
HWND hWnd,
int nCmdShow
);
BOOL ShowWindowAsync(
HWND hWnd,
int nCmdShow
);
WORD WINAPI TileWindows(
HWND hWndParent,
UINT wHow,
CONST RECT *lpRect,
UINT cKids,
const HWND FAR *lpKids
);
HWND WindowFromPoint(
POINT point
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
);
EXE's are also used as resource files. For example, the EXE might have compiled within it the icons,
cursors, bitmaps or raw data used by the EXE. These resources are created and managed with the resource
compiler, RC.
Atoms
Atoms are strings that are stored against an int index. Use the Atom for internationalization, database and index storage, and similar purposes.
Errors
Many of Windows values are revealed in errors.h and the GetLastError
function. These functions are useful to quantify and elaborate the exception model for an application.
String Handling Info
Microsoft seems to follow conventional String handling, and includes POSIX.
Message Queue
The Message Queue delivers messages in Microsoft's time slicing threading model.
The Message Queue messages are divided into application events and user events.
Messages have four parts.
Window Messages
These messages are sent to Windows open application events from the GUI system.
Messages begin with a variety of acronyms.
- ABM - Application Desktop Toolbar Messages
- BM - Button Messages
- BN - Button Messages
- CB - Combo Box Messages
- CBN - Combo Box Messages
- DM - Dialog Messages
- EM - Edit Control Messages
- EN - Edit Control Messages
- LB - List Box Messages
- LBN - List Box Messages
- SNM - Scroll Bar Messages
- STM - Static Control Messages
- STN - Static Control Messages
- WM - Most Window Controls
Windows affecting many controls are noted by WM_ then the message type, to denote Windows Message.
There are a variety of Menu Messages:
KeyBoard Input Messages are sent when keys are pressed. Mouse events are received as Mouse Messages.
There are these Painting and Drawing Messages:
Dialog Boxes
There are a variety of system provided dialog boxes. See: http://premium.microsoft.com/msdn/library/sdkdoc/dlgboxes_2eqt.htm. These dialog boxes have specialized application defined callback functions.
These structs are used when dealing with Dialog Boxes:
typedef struct _DLGITEMTEMPLATE{
DWORD style;
DWORD dwExtendedStyle;
short x;
short y;
short cx;
short cy;
WORD id;
} DLGITEMTEMPLATE;
typedef struct _DLGTEMPLATE{
DWORD style;
DWORD dwExtendedStyle;
WORD cdit;
short x;
short y;
short cx;
short cy;
} DLGTEMPLATE
typedef struct _MSGBOXPARAMS{
UINT cbSize;
HWND hWndOwner;
HINSTANCE hInstance;
LPCSTR lpszText;
LPCSTR lpszCaption;
DWORD dwStyle;
LPCSTR lpszIcon;
DWORD dwContextHelpId;
MSGBOXCALLBACK lpfnMsgBoxCallback;
DWORD dwLanguageId;
} MSGBOXPARAMS, *PMSGBOXPARAM, FAR *LPMSGBOXPARAMS;
typedef struct _DLGITEMTEMPLATEEX{
DWORD helpID;
DWORD exStyle;
DWORD style;
short x;
short y;
short cx;
short cy;
WORD id;
sz_Or_Ord windowClass;
sz_Or_Ord title;
WORD extraCount;
} DLGITEMTEMPLATEEX
typedef struct _DLGTEMPLATEEX{
WORD dlgVer;
WOR signature;
DWORD helpID;
DWORD exStyle;
DWORD style;
WORD cDlgItems;
short x;
short y;
short cx;
short cy;
sz_Or_Ord menu;
sz_Or_Ord windowClass;
WCHAR title[titleLen];
short pointSize;
short weight;
short bItalic;
WCHAR font[fontLen];
} DLGTEMPLATEEX;
There are a variety of methods for working with Dialog Boxes.
HWND CreateDialog(
HINSTANCE hINSTANCE,
LPCTSTR lpTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc
);
HWND CreateDialogIndirect(
HINSTANCE hInstance,
LPCDLGTEMPLATE lpTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc
);
HWND CreateDialogIndirectParam(
HINSTANCE hInstance,
LPCDLGTEMPLATE lpTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM lParamInit
);
HWND CreateDialogParam(
HINSTANCE hInstance,
LPCTSTR lpTemplateName,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM lParamInit
);
LRESULT DefDlgProc(
HWND hDlg,
UINT msg,
WPARAM wParam,
LPARAM lParam
);
int DialogBox(
HINSTANCE hInstance,
LPCTSTR lpTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc
);
int DialogBoxIndirect(
HINSTANCE hInstance,
LPDLGTEMPLATE lpTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc
);
int DialogBoxIndirectParam(
HINSTANCE hInstance,
LPCDLGTEMPLATE hDialogTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM dwInitParam
);
int DialogBoxParam(
HINSTANCE hInstance,
LPCTSTR lpTemplateName,
HWND hWndParent,
DLGPROX lpDialogFunc,
LPARAM dwInitParam
);
BOOL CALLBACK DialogProc(
HWND hWndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
);
BOOL EndDialog(
HWND hDlg,
int nResult
);
LONG GetDialogBaseUnits(VOID);
HWND GetDlgCtrlID(
HWND hWndCtrl
);
HWND GetDlgItem(
HWND hDlg,
int nIDDIgItem
);
UINT GetDlgItemInt(
HWND hWnd,
int nIDDIgItem,
BOOL *lpTranslated,
BOOL bSigned
);
UINT GetDlgItemText(
HWND hDlg,
int nIDDIgItem,
LPTSTR lpstring,
int nMaxCount
);
HWND GetNextDlgGroupItem(
HWND hDlg,
HWND hCtrl,
BOOL bPrevious
);
HWND GetNextDlgTabItem(
HWND hDlg,
HWND hCtrl,
BOOL bPrevious
);
BOOL IsDialogMessage(
HWND hDlg,
LPMSG lpMsg
);
BOOL MapDialogRect(
HWND hDlg,
LPRECT lpRect
);
int MessageBox(
HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType
);
int MessageBoxEx(
HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType,
WORD WLanguageId
);
LONG SendDlgItemMessage(
HWND hDlg,
int nIIDIgItem,
UINT msg,
WPARAM wParam,
LPARAM lParam
);
BOOL SetDlgItemInt(
HWND hDlg,
int nIIDIgItem,
UINT uValue,
BOOL bSigned
);
BOOL SetDlgItemText(
HWND hDlg,
int nIDDIgItem,
LPCTSTR lpString
};
int MessageBoxIndirect(
LPMSGBOXPARAMS lpMsgBoxParams
);
Messages in the Message Queue that have to do with Dialog Boxes begin with DM_ or WM_.
Buttons
Buttons are Windows Controls that reposnd to user clicks. THey are created with the CreateWindow or CreateWindowEx Window function. They can have a variety of styles, see http://premium.microsoft.com/msdn/library/sdkdoc/buttons_5ckn.htm
Read more about Button Message Processing at http://premium.microsoft.com/msdn/library/sdkdoc/buttons_5ckn.htm.
Desktop
Application Desktop Toolbar Messages let you work with the toolbar.
Edit
The Edit Control uses these messages:
Rich Edit
The Rich Edit Control has these messages:
There are also these Rich Edit Notification Messages:
Scroll Bar
There are these Scroll Bar Messages:
Static Controls
There are these command messages:
Cursor Message
There is a Cursor Message, WM_SETCURSOR.
Combo Box
Combo Boxes have these messages:
List Box
Bitmaps
Bitmap Functions
There are a number of Bitmap functions, from http://premium.microsoft.com/msdn/library/sdkdoc/bitmaps_87eb.htm.
AlphaBlend(
HDC hdcClient,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
BLENDFUNCTION blendFunction
);
BOOL BitBlt(
HDC hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
HDC hdcSrc,
int nXSrc,
int nYSrc,
DWORD dwRop
);
HBITMAP CreateBitmap(
int nWidth,
int nHeight,
UINT cPlanes,
UINT cBitsPerPixel,
CONST VOID *lpvBits
);
HBITMAP CreateBitmapIndirect(
CONST BITMAP *lpbm
);
HBITMAP CreateCompatibleBitmap(
HDC hdc,
int nWidth,
int nHeight
);
HBITMAP CreateDIBitmap(
HDC hdc,
CONST BITMAPINFOHEADER,
DWORD fdwInit,
CONST VOID *lpbInit,
CONST BITMAPINFO *lpbmi,
UINT fuUsage
);
HBITMAP CreateDIBSection(
HDC hdc,
CONST BITMAPINFO *pbmi,
UINT iUsage,
VOID *ppvBits,
HANDLE hSection,
DWORD dwOffset
);
BOOL ExtFloodFill(
HDC hdc,
int nXStart,
int nYStart,
COLORREF crColor,
UINT fuFillType
);
BOOL GetBitmapDimensionEx(
HBITMAP hBitmap,
LPSIZE lpDimension
);
UINT GetDIBColorTable(
HDC hdc,
UINT uStartIndex,
UINT cEntries,
RGBQUAD *pColors
);
int GETDIBits(
HDC hdc,
HBITMAP hBmp,
UINT uStartScan,
UINT cScanLines,
LPVOID lpvBits,
LPBITMAPINFO lpbi,
UINT uUsage
);
COLORREF GetPixel(
HDC hdc,
int xPos,
int yPos
);
int GetStretchBltMode(
HDC hdc
);
BOOL GradientFill(
HDC hdc,
CONST PTRIVERTEX pVertex,
DWORD dwNumVertex,
CONST PVOID pMesh,
DWORD dwNumMesh,
DWORD dwMode
);
MaskBlt(
HDC hdcDest,
int xDest,
int yDest,
int nWidth,
int nHeight,
HDC hdcSrc,
int nXSrc,
int nYSrc,
HBITMAP hbmMask,
int xMask,
int yMask,
DWORD dwRop
);
BOOL PatBlt(
HDC hdc,
int nXLeft,
int nYLeft,
int nWidth,
int nHeight,
DWORD dwrop
);
BOOL PlgBlt(
HDC hdcDest
CONST POINT *lpPoint
HDC hdcSrc
int nXSrc,
int nYSrc,
int nWidth,
int nHeight,
HBITMAP hbmMask,
int xMask,
int yMask
);
BOOL SetBitmapDimensionEx(
HBITMAP hBitmap,
int nWidth,
int nHeight,
LPSIZE lpSize
);
UINT SetDIBColorTable(
HDC hdc,
UINT uStartIndex,
UINT cEntries,
CONST RGBQUAD *pColors
);
int SetDIBits(
HDC hdc,
HBITMAP hBmp,
UINT uStartScan,
UINT cScanLines,
CONST VOID *lpvBits,
CONST BITMAPINFO *lpbmi,
UINT fuColorUse
);
int SetDIBitsToDevice(
HDC hdc,
int xDest,
int yDest,
DWORD dwWidth,
DWORD dwHeight,
int xSrc,
int ySrc,
UINT uStartScan,
UINT cScanLines,
CONST VOID *lpvBits,
CONST BITMAPINFO *lpbmi,
UINT fuColorUse
);
COLORREF SetPixel(
HDC hdc,
int x,
int y,
COLORREF crColor
);
BOOL SetPixelV(
HDC hdc,
int x,
int y,
COLORREF crColor
);
int SetStretchBltMode(
HDC hdc,
int iStertchMode
);
BOOL StretchBlt(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int nHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthOriginSrc,
int nHeightOriginSrc,
DWORD dwRop
);
int StretchDIBits(
HDC hdc,
int xDest,
int yDest,
int nDestWidth,
int nDestHeight,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight,
CONST VOID *lpBits,
CONST BITMAPINFO *lpBitsInfo,
UINT iUsage,
DWORD dwRop
);
BOOL TransparentBlt(
HDc hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int nHeightDest,
int HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc
UINT crTransparent
);
Color Functions
These are the color functions, from http://premium.microsoft.com/msdn/library/sdkdoc/colors_61v7.htm.
BOOL AnimatePalette(
HPALETTE hPal,
UINT iStartIndex,
UINT cEntries,
CONST PALETTEENTRY *ppe
);
HPALETTE CreateHalftonePalette(
HDC hdc
);
HPALETTE CreatePalette(
CONST LOGPALETTE *lplgpl
);
BOOL GetColorAdjustment(
HDC hdc,
LPCOLORADJUSTMENT lpca
);
COLORREF GetNearestColor(
HDC hdc,
COLORREF crColor
);
UINT GetNearestPaletteIndex(
HPALETTE hPal,
COLORREF crColor
);
UINT GetPaletteEntries(
HPALETTE hPal,
UINT iStartIndex,
UINT nEntries,
LPPALETTEENTRY lppe
);
UINT GetSystemPaletteEntries(
HDC hdc,
UINT iStartIndex,
UINT nEntries,
LPPALETTEENTRY lppe
);
UINT GetSystemPaletteUse(
HDC hdc
);
UINT RealizePalette(
HDC hdc
);
BOOL ResizePalette(
HPALETTE hPal,
UINT nEntries,
);
HPALETTE SelectPalette(
HDC
HPALETTE hPal,
BOOL bForceBackground
);
BOOL SetColorAdjustment(
HDC hdc,
CONST COLORADJUSTMENT *lpca
);
UINT SetPaletteEntries(
HPALETTE hPal,
UINT iStart,
UINT cEntries,
CONST PALETTEENTRY *lppa
);
UINT SetSystemPaletteUse(
HDC hdc,
UINT uUsage
);
BOOL UnrealizeObject(
HGDIOBJ hgdiobj
);
BOOL UpdateColors(
HDC hdc
);
Windows Threads
There are these Process and Thread functions, from this page http://premium.microsoft.com/msdn/library/sdkdoc/prothred_7mib.htm:
BOOL AssignProcessToJobObject(
HANDLE hJob
HANDLE hProcess
);
BOOL AttachThreadInput(
DWORD idAttach,
DWORD idAttachTo,
BOOL fAttach
);
LPWSTR * CommandLineToArgW(
LPCWSTR lpCmdLine,
int *pNumArgs
);
BOOL CreateProcess(
LPCTSTR lpApplicationName,
LPTSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCTSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInfo
);
BOOL CreateProcessAsUser(
HANDLE htoken,
LPCTSTR lpApplciationName,
LPTSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCTSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInfo
);
HANDLE CreateRemoteThread(
HANDLE hProcess;
LPSECURITY_ATTRIBUTES lpThreadAttributes,
DWORD dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddess,
LPVOID lpParam,
DWORD dwCreationFlags,
LPDWORD lpThreadId
);
HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,
DWORD dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddess,
LPVOID lpParam,
DWORD dwCreationFlags,
LPDWORD lpThreadId
);
VOID ExitProcess(
UINT uExitCode
);
VOID ExitThread(
DWORD dwExitCode
);
BOOL FreeEnvironmentSettings(
LPTSTR lpszEnvironmentBlock
);
LPTSTR GetCommandLine(VOID);
HANDLE GetCurrentProcess(VOID);
DWORD GetCurrentProcessId(VOID);
HANDLE GetCurrentThread(VOID);
DWORD getCurrentThreadId(VOID);
LPVOID GetEnvironmentStrings(VOID);
DWORD GetEnvironmentVariable(
LPCTSTR lpName,
LPTSTR lpBuffer,
DWORD nSize
);
BOOL GetExitCodeProcess(
HANDLE hProcess,
LPDWORD lpExitCode
);
BOOL GetExitCodeThread(
HANDLE hThread,
LPDWORD lpExitCode
);
DWORD GetGuiResources(
HANDLE hProcess,
DWORD uiFlags
);
DWORD GetPriorityClass(
HANDLE hProcess
);
BOOL GetProcessAffinityMask(
HANDLE hProcess,
LPDWORD lpProcessAffinityMask,
LPDWORD lpSystemAffinityMask
);
BOOL GetProcessShutdownParameters(
LPDWORD lpdwLevel,
LPDWORD lpdwFlags
);
BOOL GetProcessPriorityBoost(
HANDLE hProcess,
PBOOL pDisablePriorityBoost
);
BOOL GetProcessTimes(
HANDLE hProcess,
LPFILETIME lpCreationTime,
LPFILETIME lpExitTime,
LPFIELTIME lpKernelTime,
LPFILETIME lpUserTime
);
DWORD GetProcessVersion(
DWORD processId
);
BOOL GetProcessWorkingSetSize(
HANDLE hProcess,
LPDWORD lpMinimumWorkingSetSize,
LPDWORD lpMaximumWorkingSetSize
);
VOID GetStartupInfo(
LPSTARTUPINFO lpStartupInfo
);
int GetThreadPriority(
HANDLe hThread
);
BOOL GetThreadPriorityBoost(
HANDLe hThread,
PBOOL pDisablePriorityBoost
);
BOOL GetThreadTimes(
HANDLE hThread,
LPFILETIME lpCreationTime,
LPFILETIME lpExitTime,
LPFILETIME lpKernelTime,
LPFILETIME lpUserTime
);
HANDLE OpenProcess(
DWORD dwDesiredAccess,
BOOL bInheritHandle,
DWORD dwProcessId
);
DWORD ResumeThread(
HANDLE hThread
);
BOOL SetEnvironmentVariable(
LPCTSTR lpName,
LPCTSTR lpValue
);
BOOL SetPriorityClass(
HANDLE hProcess
DWORD dwPriorityClass
);
BOOL SetProcessAffinityMask(
HANDLE hProcess,
DWORD dwProcessAffinityMask
);
BOOL SetProcessShutdownParameters(
DWORD dwLevel,
DWORD dwFlags
);
BOOL SetProcessPriorityBoost(
HANDLE hProcess,
BOOL disablePriorityBoost
);
BOOL SetProcessWorkingSetSize(
HANDLE hProcess,
DWORD dwMinimumSize,
DWORD dwMaximumSize
);
DWORD SetThreadAffinityMask(
HANDLE hThread,
DWORD dwThreadAffinityMask
);
DWORD SetThreadIdealProcessor(
HANDLE hThread,
DWORD dwIdealProcessor
);
BOOL SetThreadPriority(
HANDLE hThread,
int nPriority
);
BOOL SetThreadPriorityBoost(
HANDLE hThread,
BOOL disabledPriorityBoost
);
VOID Sleep(
DWORD dwMilliseconds
)
DWORD SleepEx(
DWORD dwMilliseconds
BOOL bAlertable
);
DWORD SuspendThread(
HANDLE hThread
);
BOOL SwitchToThread(VOID)
BOOL TerminateProcess(
HANDLE hProcess,
UINT uExitCode
);
BOOL TerminateThread(
HANDLE hThread,
DWORD dwExitCode
);
DWORD WINAPI ThreadProc(
LPVOID lpParam
);
DWORD TlsAlloc(VOID);
BOOL TlsFree(
DWORD dwTlsIndex
);
LPVOID TlsGetValue(
DWORD dwTlsIndex
);
BOOL TlsSetValue(
DWORD dwTlsIndex,
LPVOID lpTlsValue
);
DWORD WaitForInputIdle(
HANDLE hProcess,
DWORD dwMilliseconds
);
Job Objects
These functions are used with Job Objects:
BOOL AssignProcessToJobObject(
HANDLE hJob,
HANDLE hProcess
);
HANDLE CreateProcessGroupJobObject(
LPSECURITY_ATTRIBUTES lpJobAttributes,
LPCTSTR lpName
);
HANDLE OpenJobObject(
DWORD dwDesiredAccess,
BOOL bInheritHandles,
LPCTSTR lpName
);
BOOL QueryInformationJobObject(
HANDLE hJob,
JOBJECTINFOCLASS jObObjectInfoClass,
LPVOID lpJobObjectInformation,
DWORD cbJobObjectInfoLength,
LPDWORD lpReturnLength
);
BOOL SetInformationJobObject(
HANDLE hJob,
JOBJECTINFOCLASS jobObjectInfoClass,
LPVOID lpJobObjectInfo,
DWORD cbJobInfoLength
);
BOOL TerminateJobObject(
HANDLE hJob,
UINt uExitCode
);
BOOL UserHandleGrantAccess(
HANDLE h,
HANDLE hJob
);
Fibers
There are these function used with Fibers:
LPVOID ConvertThreadtoFiber(
LPVOID lpParam
);
LPVOID CreateFiber(
DWORD dwStackSize,
LPFIBER_START_ROUTINE lpStartAddress,
LPVOID lpParam
);
VOID DeleteFiber (
LPVOID lpFiber
);
VOID CALLBACK FiberProc(
PVOID lpParam
);
PVOID GetCurrentFiber(VOID);
PVOID GetFiberData(VOID);
VOID SwitchToFiber(
LPVOID lpFiber
);
Windows has threads.
Exception handling can be used with C++ for try/catch/finally exception handling.
Files
Windows has a variety of file functions. These are from http://premium.microsoft.com/msdn/library/sdkdoc/filesio_6nqr.htm.
BOOL AreFileApisANSI();
BOOL CancelIo(
HANDLE hFile
);
BOOL CopyFile(
LPCTSTR lpExistingFileNAme
LPCTSTR lpNewFileNAme,
BOOL bFailIfExists
);
BOOL CopyFileEx(
LPCWSTR lpExistingFileName,
LPCWSTR lpNewFileNAme,
LPPROGRESS_ROUTINE lpProgressRoutine,
LPVOID lpData,
LPBOOL pbCancel,
DWORD dwCopyFlags
);
DWORD CALLBACK CopyProgressRoutine(
LARGE_INTEGER totalFileSize,
LARGE_INTEGER totalBytesTransferred,
LARGE_INTEGER streamSize,
LARGE_INTEGER streamBytesTransferred,
DWORD dwStreamNumber,
DWORD dwCallbackReason,
HANDLE hSourceFile,
HANDLE hDestinationFile,
LPVOID lpData
);
BOOL CreateDirectory(
LPCTSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
BOOL CreateDirectoryEx(
LPCTSTR lpTemplateDirectory,
LPCTSTR lpNewDirectory,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
HANDLE CreateFile(
LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
);
HANDLE CreateIoCompletionPort(
HANDLE fileHandle,
HANDLE existingCompletionPort,
DWORD completionKey
DWORD numberOfConcurrentThreads
);
BOOL DefineDosDevice(
DWORD dwFlags,
LPCTSTR lpDeviceName,
LPCTSTR lpTargetPath
);
BOOL DeleteFile(
LPCTSTR lpFileName
);
VOID CALLBACK FileIOCompletionRoutine(
DWORD dwErrorCode,
DWORD dwNumberOfBytesTransferred,
LPOVERLAPPED lpOverlapped
);
BOOL FindClose(
HANDLE hFindFile
);
BOOL FindCloseChangeNotification(
HANDLE hChangeHandle
);
HANDLE FindFirstChangeNotification(
LPCTSTR lpPathName,
BOOL bWatchSubtree,
DWORD dwNotifyFilter
);
HANDLE FindFirstFile(
LPCTSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
);
HANDLE FindFirstFileEx(
LPCTSTR lpFileName,
FINDEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFindFileData,
FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter,
DWORD dwAdditionalFlags
);
BOOL FindNextChangeNotification(
HANDLE hChangeHandle
);
BOOL FindNextFile(
HANDLE hFindFile,
LPWIN32_FIND_DATA lpFindFileData
);
BOOL FlushFileBuffers(
HANDLE hFile
);
BOOL GetBinaryType(
LPCTSTR lpapplicationName,
LPDWORD lpBinaryType
);
DWORD GetCompressedFileSize(
LPCTSTR lpFileName,
LPDWORD lpFileSizeHigh
);
DWORD GetCurrentDirectory(
DWORD nBufferLength,
LPTSTR lpBuffer
);
BOOL GetDiskFreeSpace(
LPCTSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters,
LPDWORD lpTotalNumberOfCluster
);
BOOL GetDiskFreeSpaceEx(
LPCTSTR lpDirectoryName
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
PULARGE_INTEGER lpTotalNumberOfBytes,
PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
UINT GetDriveType(
LPCTSTR lpRootPathName
);
DWORD GetFileAttributes(
LPCTSTR lpFileName
);
BOOL GetFileAttributeEx(
LPCTSTR lpFileName,
GET_FILEEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFileInformation
);
BOOL GetFileInformationByHandle(
HANDLE hFile,
LPBY_HANDLE_FILE_INFORMATION lpFileInformation
);
DWORD GetFileSize(
HANDLE hFile,
LPDWORD lpFileSizeHigh
);
DWORD GetFileType(
HANDLE hFile
);
DWORD GetFullPathName(
LPCTSTR lpFileName,
DWORD nBufferLength,
LPTSTR lpBuffer,
LPTSTR *lpFilePort
);
DWORD GetLogicalDrives(VOID);
DWORD GetLogicalDriveStrings(
DWORD nBufferLength,
LPTSTR lpBuffer
);
DWORD GetLongPathName(
LPCTSTR lpszShortPath,
LPTSTR lpszLongPath,
DWORD cchBuffer
);
BOOL GetQueuedCompletionStatus(
HANDLE completionPort,
LPDWORD lpNumberOfBytesransferred,
LPDWORD lpCompletionKey,
LPOVERLAPPED *lpOverLapped,
DWORD dwMilliseconds
)
DWORD GetShortPathName(
LPCTSTR lpszLongPath,
LPTSTR lpszShortPath,
DWORD cchBuffer
);
UINT GetTempFileName(
LPCTSTR lpPathName,
LPCTSTR lpPrefixString,
UINT uUnique,
LPTSTR lpTempFileName
);
DWORD GetTempPath(
DWORD nBufferLength,
LPTSTR lpBuffer
);
BOOL LockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfByteToLockLow,
DWORD nNumberOfBytesToLockHigh
);
BOOL LockFileEx(
HANDLE hFile,
DWORD dwFlags,
DWORD dwReserved,
DWORD nNumberOfByteToLockLow,
DWORD nNumberOfBytesToLockHigh
);
BOOL MoveFile(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName
);
BOOL MoveFileEx(
LPCTSTR lpExistingFileNAme,
LPCTSTR lpNewFileName,
DWORD dwFlags
);
BOOL PostQueuedCompletionStatus(
HANDLE completionPort,
DWORD dwNumberOfBytesTransferred,
DWORD completionKey,
LPOVERLAPPED lpOverlapped
);
DWORD QueryDosDevice(
LPCTSTR lpDeviceName,
LPTSTR lpTargetPath,
DWORD ucchMax
);
BOOL ReadDirectoryChangesW(
HANDLe hFirectory,
LPVOID lpBuffer,
DWORD nBufferLength,
BOOL bWatchSubtree,
DWORD dwNotifyFilter,
LPDWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped,
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
);
BOOL ReadFile(
HANDLe hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
);
BOOL ReadFileEx(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNmberOfBytesToRead,
LPOVERLAPPED lpOverlapped,
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
);
BOOL ReadFileScatter(
HANDLE hFile,
FILE_SEGMENT_ELEMENT aSegmentArray[],
DWORD nNumberOfBytesToRead,
LPDWORD lpReserved,
LPOVERLAPPED lpOverlapped,
);
BOOL RemoveDirectory(
LPCTSTR lpPathName
);
DWORD SearchPath(
LPCTSTR lpPath,
LPCTSTR lpFileName,
LPCTSTR lpExtension,
DWORD nBufferLength,
LPTSTR lpBuffer,
LPTTR *lpFilePart
);
BOOL SetCurrentDirectory(
LPCTSTR lpPathName
);
BOOL SetEndOfFile(
HANDLE hFile
);
VOID SetFileApisToANSI(VOID);
VOID SetFileApisToOEM(VOID);
BOOL SetFileAttributes(
LPCTSTR lpFileName,
DWORD dwFileAttributes
);
DWORD SetFilePointer(
HANDLE hFile,
LONG lDistanceToMove,
PLONG lpDistanceToMoveHigh,
DWORD dwMoveMethod
);
BOOL SetVolumeLabel(
LPCTSTR lpRootPathName,
LPCTSTR lpVolumeName
);
BOOL UnlockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow,
DWORD nNumberOfBytesToUnlockHigh
);
BOOL UnlockFileEx(
HANDLE hFile,
DWORD dwReserved,
DWORD nNumberOfBytesToUnlockLow,
DWORD nNumberOfBytesToUnlockHigh,
LPOVERLAPPED lpOverlapped
);
BOOL WriteFile(
HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesToWrite,
LPOVERLAPPED lpOverlapped
);
BOOL WriteFileEx(
HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPOVERLAPPED lpOverlapped,
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
);
BOOL WriteFileGather(
HANDLE hFile,
FILE_SEGMENT_ELEMENT aSegmentArray[]
DWORD nNumberOfBytesToWrite,
LPDWORD lpReserved,
LPOVERLAPPED lpOverlapped
);
Memory Management
These structures are used with Memory Management functions:
typedef struct _MEMORY_BASIC_INFORMATION {
PVOID BaseAddress;
PVOID AllocationBase;
DWORD AllocationProtect;
DWORD RegionSize;
DWORD State;
DWORD Protect;
DWORD Type;
} MEMORY_BASIC_INFORMATION;
typedef MEMORY_BASIC_INFORMATION *PMEMORY_BASIC_INFORMATION;
typedef struct _MEMORYSTATUS {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORD dwTotalPhys;
DWORD dwAvailPhys;
DWORD dwTotalPageFile;
DWORD dwAvailPageFile;
DWORD dwTotalVirtual;
DWORD dwAvailVirtual;
} MEMORYSTATUS, *LPMEMORYSTATUS;
typedef struct _PROCESS_HEAP_ENTRY {
PVOID lpData;
DWORD cbData;
BYTE cbOverhead;
BYTE iRegionIndex;
WORD wFlags;
union{
struct{
HANDLE hMem;
DWORD dwReserved[3];
} Block;
struct{
DWORD dwCommittedSize;
DWORD dwUnCommittedSize;
LPVOID lpFirstBlock;
LPVOID lpLastBlock;
} Region;
};
} PROCESS_HEAP_ENTRY;
There are these memory management functions, from http://premium.microsoft.com/msdn/library/sdkdoc/memman_7jmt.htm.
VOID CopyMemory(
PVOID destination,
CONST VOID *source,
DWORD length
);
VOID FillMemory(
PVOID destination,
DWORD length,
BYTE fill
);
HANDLE GetProcessHeap(VOID);
DWORD GetProcessHeaps(
DWORD numberOfHeaps,
PHANDLE processHeaps
);
HGLOBAL GlobalAlloc(
UINT uFlags,
DWORD dwBytes
);
HGLOBAL GlobalDiscard(
HGLOBAL hglbMem
);
UINT GlobalFlags(
HGLOBAL hMem
);
HGLOBAL GlobalFree(
HGLOBAL hMem
);
HGLOBAL GlobalHandle(
LPCVOID pMem
);
LPVOID GlobalLock(
HGLOBAL hMem
);
VOID GlobalMemoryStatus(
LPMEMORYSTATUS lpBuffer
);
HGLOBAL GlobalReAlloc(
HGLOBAL hMem,
DWORD dwBytes,
UINT uFlags
);
DWORD GlobalSize(
HGLOBAL hMem
);
BOOL GlobalUnlock(
HGLOBAL hMem
);
LPVOID HeapAlloc(
HANDLE hHeap,
DWORD dwFlags,
DWORD dwBytes
);
UINT HeapCompact(
HANDLE hHeap,
DWORD dwFlags
);
HANDLE HeapCreate(
DWORD flOptions,
DWORD dwInitialSize,
DWORD dwMaximumSize
);
BOOL HeapDestroy(
HANDLe hHeap
);
BOOL HeapFree(
HANDLE hHeap,
DWORD dwflags,
LPVOID lpMem
);
BOOL HeapLock(
HANDLE hHeap
);
LPVOID HeapReAlloc(
HANDLE hHeap,
DWORD dwFlags,
LPVOID lpMem,
DWORD dwBytes
);
DWORD HeapSize(
HANDLE hHeap,
DWORD dwFlags,
LPCVOID lpMem
);
BOOL HeapUnlock(
HANDLE hHeap
);
BOOL HeapValidate(
HANDLE hHeap,
DWORD dwFlags,
LPCVOID lpMem
);
BOOL HeapWalk(
HANDLE hHeap,
LPPROCESS_HEAP_ENTRY lpEntry
);
BOOL IsBadCodePtr(
FARPROC lpfn
);
BOOL IsBadHugeReadPtr(
CONST VOId *lp,
UINT ucb
);
BOOL IsBadHugeWritePtr(
LPVOID lp,
UINT ucb
);
BOOL IsBadReadPtr(
CONST VOID *lp,
UINT ucb
);
BOOL IsBadStringPtr(
LPCTSTR lpsz,
UINT ucchMax
);
BOOL IsBadWritePtr(
LPVOID lp,
UINT ucb
);
HLOCAL LocalAlloc(
UINT uFlags,
UINT uBytes
);
HLOCAL LocalDiscard(
HLOCAL hLocalMem
);
UINT LocalFlags(
HLOCAL hMem
);
HLOCAL LocalFree(
HLOCAL hMem
);
HLOCAL LocalHandle(
LPCVOID pMem
);
LPVOID LocalLock(
HLOCAL hMem
);
HLOCAL LocalReAlloc(
HLOCAL hMem,
UINT uBytes,
UINT uFlags
);
UINT LocalSize(
HLOCAL hMem
);
BOOL LocalUnlock(
HLOCAL hMem
);
VOID MoveMemory(
PVOID destination,
CONST VOID *source,
DWORD length
);
LPVOID VirtualAlloc(
LPVOID lpAddress,
DWORD dwSize,
DWORD flAllocationType,
DWORD flProtect
);
LPVOID VirtualAllocEx(
HANDLE hProcess,
LPVOID lpAddress,
DWORD dwSize,
DWORD flAllocationType,
DWORD flProtect
);
BOOL VirtualFree(
LPVOID lpAddress,
DWORD dwSize,
DWORD dwFreeType
);
BOOL VirtualFreeEx(
HANDLE hProcess,
LPVOID lpAddress,
DWORD dwSize,
DWORD dwFreeType
);
BOOL VirtualLock(
LPVOID lpAddress,
DWORD dwSize
);
BOOL VirtualProtect(
LPVOID lpAddress,
DWORD dwSize,
DWORD flNewProtect,
PDWORD lpflOldProtect
);
BOOL VirtualProtectEx(
HANDLE hProcess,
LPVOID lpAddress,
DWORD dwSize,
DWORD flNewProtect,
PDWORD lpflOldProtect
);
DWORD VirtualQuery(
LPCVOID lpAddress,
PMEMORY_BASIC_INFORMATION lpBuffer,
DWORD dwLength
);
DWORD VirtualQueryEx(
HANDLE hProcess,
LPCVOID lpAddress,
PMEMORY_BASIC_INFORMATION lpBuffer,
DWORD dwLength
);
BOOL VirtualUnlock(
LPVOID lpAddress,
DWORD dwsize
);
VOID ZeroMemory(
PVOID destination,
DWORD length
);
Time Functions
These structures are used with Time:
typedef struct _FILETIME{
DWORD dwLowDateTime;
DWORD dwHighDAteTime;
} FILETIME;
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
typedef struct _TIME_ZONE_INFORMATION {
LONG Bias;
WCHAR StandardName[32];
SYSTEMTIME StandardDate;
LONG StandardBias;
WCHAR DaylightName[32];
SAYSTEMTIME DaylightDate;
LONG DaylightBias;
} TIME_ZONE_INFORMATION;
Here are the Time Functions from the Win32 API: http://premium.microsoft.com/msdn/library/sdkdoc/time_4po3.htm.
LONG CompareFileTime(
CONST FILETIME *lpFileTime1,
CONST FILETIME *lpFileTime2
);
BOOL DosDateTimeToFileTime(
WORD wFatDAte,
WORD wFattime,
LPFILETIME lpFileTime
);
BOOL FileTimeToDosDateTime(
CONST FILETIME *lpFileTime,
LPWORD lpFatDate,
LPWORD lpFatTime
);
BOOL FileTimeToLocalFileTime(
CONST FILETIME *lpFileTime,
LPFILETIME lpLocalFileTime
);
BOOL FileTimeToSystemTime(
CONST FILETIME *lpFileTime,
LPSYSTEMTIME lpSystemTime
);
BOOL GetFileTime(
HANDLE hFile,
LPFILETIME lpCreationTime,
LPFILETIME lpLastAccessTime,
LPFILETIME lpLastWriteTime
);
VOID GetLocalTime(
LPSYSTEMTIME lpSystemTime
);
VOID GetSystemTime(
LPSYSTEMTIME lpSystemTime
);
BOOL GetSystemTimeAdjustment(
PDWORD lptimeAdjustment,
PDWORD lpTimeIncrement,
PBOOL lpTimeAdjustmentDisabled
);
VOID GetSystemTimeAsFileTime(
LPFILETIME lpSystemTimeAsFileTime
);
DWORD GetTickCount(VOID);
DWORD GetTimeZoneInformation(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation
);
BOOL LocalFileTimeToFileTime(
CONST FILETIME *lpLocalFileTime,
LPFILETIME lpFileTime
);
BOOL SetFileTime(
HANDLE hFile,
CONST FILETIME *lpCreationTime,
CONST FILETIME *lpLastAccessTime,
CONST FILETIME *lpLastWriteTime
);
BOOL SetLocalTime(
CONST SYSTEMTIME *lpSystemTime
);
BOOL SetSystemTime(
CONST SYSTEM *lpSystemTime
);
BOOL SetSystemTimeAdjustment(
DWORD dwTimeAdjustment,
BOOL bTimeAdjustmentDisabled
);
BOOL SetTimeZoneInformation(
CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation
);
BOOL SystemTimeToFileTime(
CONST SYSTEMTIME *lpSystemTime,
LPFILETIME lpFileTime
);
BOOL SystemTimeToTzSpecificLocalTime(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
LPSYSTEMTIME lpUniversalTime,
LPSYSTEMTIME lpLocalTime
};
Strings
There are four structs used with String Manipulation functions:
struct _CPINFO{
UINT MaxCharSize;
BYTE DefaultChar[MAX_DEFAULTCHAR];
BYTE LeadByte[MAX_LEADBYTES];
} CPINFO;
typedef struct _CPINFOEX{
UNINT MaxCharSize;
BYTE DefaultChar[MAX_DEFAULTCHAR];
BYTE LeadByte[MAX_LEADBYTES];
WCHAR UnicodeDefaultChar;
UINT CodePAge;
TCHAR CodePageName[MAX_APTH];
} CPINFOEX *LPCPINFOEX;
typedef struct _CURRENCYFMT {
UINT NumDigits;
UINT LeadingZero;
UINT Grouping;
LPTSTR lpDecimalSep;
LPTSTR lpThousandSep;
UINT negativeOrder;
UINT positiveOrder;
LPTSTR lpCurrentSymbol;
} CURRENCYFMT;
typedef struct _NUMBERFMT {
UINT NumDigits;
UINT LeadingZero;
UINT Grouping;
LPTSTR lpDecimalSep;
LPTSTR lpThousandSep;
UINT NegativeOrder;
} NUMBERFMT;
These functions are used with String Manipulation, from http://premium.microsoft.com/msdn/library/sdkdoc/strings_0qp1.htm.
LPTSTR CharLower(
LPTSTR lpsz
);
DWORD CharLowerBuff(
LPTSTR lpsz,
DWORD cchLength
);
LPTSTR CharNext(
LPCTSTR lpsz
);
LPTSTR CharNextExA(
WORD codePage,
LPCSTR lpCurrentChar,
DWORD dwflags
);
LPTSTR CharPrev(
LPCTSTR lpszStart,
LPCTSTR lpszCurrent
);
LPTSTR CharPrevExA(
WORD codePage,
LPCSTR lpStart,
LPCSTR lpCurrentChar,
DWORD dwFlags
);
BOOL CharToOem(
LPCTSTR lpszSrc,
LPSTR lpszDest
);
BOOL CharToOemBuff(
LPCTSTR spszSrc,
LPSTR lpszDest,
DWORD cchDestLength
);
LPTSTR CharUpper(
LPTSTR lpsz
);
DWORD CharUpperBuff(
LPTSTR lpsz,
DWORD cchLength
);
int CompareString(
LCID locale,
DWORD dwCmpFlags,
LPCTSTR lpString1,
int cchCount1,
LPCTSTR lpString2,
int cchCount2
);
LCID ConvertDefaultLocale(
LCID locale
);
BOOL EnumCalendarInfo(
CALINFO_ENUMPROC lpCalInfoEnumProc,
LCID locale,
CALID calendar,
CALTYPE calType
);
BOOL EnumCalendarInfoEx(
CALINFO_ENUMPROCEX lpCalInfoEnumProcEx
LCID locale,
CALID calendar,
CALTYPE calType
);
BOOL CALLBACK EnumCalendarInfoProc(
LPTSTR lpCalendarInfoString
);
BOOL CALLBACK EnumCalendarInfoProcEx(
LPTSTR lpcalendarInfoString,
CALID calendar
);
BOOL CALLBACK EnumCodePagesProc(
LPTSTR lpCodePageString
);
BOOL EnumDateFormats(
DATEFMT_ENUMPROC lpDataFmtEnumProc,
LCID locale,
DWORD dwFlags
);
BOOL CALLBACK EnumDateFormatsProc(
LPTSTR lpDateFormatString
);
BOOL CALLBACK EnumLocalesProc(
LPTSTR lpLocaleString
);
BOOL EnumSystemCodePages(
CODEPAGE_ENUMPROC lpCodePageEnumProc,
DWORD dwFlags
);
BOOL EnumSystemLocales(
LOCALE_ENUMPROC lpLocaleEnumProc,
DWORD dwFlags
);
BOOL EnumTimeFormats(
TIMEFMT_ENUMPROC lpTimeFmtEnumProc,
LCID locale,
DWORD dwFlags
);
BOOL CALLBACK EnumTimeFormatsProc(
LPTSTR lpTimeFormatString
);
int FoldString(
DWORD dwMapFlags,
LPCTSTR lpSrcStr,
int cchSrc,
LPTSTR lpDestStr,
int cchDest
);
DWORD FormatMessage(
DWORD dwFlags,
LPCVOID lpSource,
DWORD dwMessageId,
DWORD dwLanguageId,
LPTSTR lpBuffer,
DWORD nSize,
va_list *Arguments
);
UINT GetACP(VOID);
BOOL GetCPInfo(
UINT codePage,
LPCPINFO lpCPInfo
);
BOOL GetCPInfoEx(
UINT codePAge,
DWORD dwFlags,
LPCPINFOEX lpCPInfoEx
);
int GetCurrencyFormat(
LCID locale,
DWORD dwFlags,
LPCSTR lpValue,
CONST CURRENCYFMT *lpFormat,
LPTSTR lpCurrenctStr,
int cchCurrency
);
int GetDateFormat(
LCID locale,
DWORD dwFlags,
CONST SYSTEMTIME *lpDate,
LPCTSTR lpFormat,
LPTSTR lpDateStr,
int cchDate
);
int GetLocaleInfo(
LCID locale,
LCTYPE lCType,
LPTSTR lpLCData,
int cchData
);
int GetNumberFormat(
LCID locale,
DWORD dwFlags,
LPCTSTR lpValue,
CONST NUMBERFMT *lpFormat,
LPTSTR lpNumberStr,
int cchNumber
);
UINT GetOEMCP(VOID);
BOOL GetStringTypeA(
LCID locale,
DWORD dwInfoType,
LPCSTR lpSrcStr,
int cchSrc,
LPWORD lpCharType
);
BOOL GetStringTypeEx(
LCID locale,
DWORD dwInfoType,
LPCTSTR lpSrcStr,
int cchSrc,
LPWORD lpCharType
};
BOOL GetStringTypeW(
DWORD dwInfoType,
LPCWSTR lpSrcStr,
int cchSrc,
LPWORD lpCharType
);
LANGID GetSystemDefaultLangID(VOID);
LCID GetSystemDefaultLCID(VOID);
LCID GetThreadLocale(VOID)
int GetTimeFormat(
LCID locale,
DWORD dwFlags,
CONST SYSTEMTIME *lpTime,
LPCTSTR lpFormat,
LPTSTR lpTimeStr,
int cchTime
);
LANGID GetUserDefaultLangID(VOID);
LCID GetUserDefaultLCID(VOID);
BOOL IsCharAlpha(
TCHAR ch
);
BOOL IsCharAlphaNumeric(
TCHAR ch
);
BOOL IsCharLower(
TCHAR ch
);
BOOL IsCharUpper(
TCHAR ch
);
BOOL IsDBCSLeadByte(
BYTE testChar
);
DWORD IsTextUnicode(
CONST LPVOID lpBuffer,
int cb,
LPINT lpi
);
BOOL IsValidCodePage(
UINT codePAge
);
BOOL IsValidLocale(
LCID locale,
DWORD dwFlags
);
int LCMapString(
LCID locale,
DWORD dwMapFlags,
LPCTSTR lpSrcStr,
int cchSrc,
LPTSTR lpDestStr,
int cchDest
);
int LoadString(
HINSTANCE hInstance,
UINT uID,
LPTSTR lpBuffer,
int nBufferMax
);
LPTSTR lstrcat(
LPTSTR lpString1,
LPCTSTR lpstring2
);
int lstrcmp(
LPCTSTR lpString1,
LPCTSTR lpString2
);
int lstrcmpi(
LPCTSTR lpString1,
LPCTSTR lpString2
);
LPTSTR lstrcpy(
LPTSTR lpString1,
LPCTSTR lpString2
);
LPTSTR lstrcpyn(
LPTSTR lpString1,
LPCTSTR lpString2,
int iMaxLength
);
int lstrlen(
LPCTSTR lpString
);
int MultiByteToWideChar(
UINT codePAge,
DWORD dwFlags,
LPCSTR lpMultiByteAddr,
int cchMultiByte,
LPWSTR lpWideCharStr,
int cchWideChar
);
BOOL OemToChar(
LPCSTR lpscSrc,
LPTSTR lpscDest
);
BOOL OemToCharBuff(
LPCSTR lpszSrc,
LPTSTR lpszDest,
DWORD cchDestLength
);
BOOL SetLocaleInfo(
LCID locale,
LCTYPE lCType,
LPCTSTR lpLCData
);
BOOL SetThreadLocale(
LCID locale
);
int WideCharToMultiByte(
UINT codePAge,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
LPSTR lpMultiByteStr,
int cchMultiByte,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar
);
int wsprintf(
LPTSTR lpOut,
LPCTSTR lpFmt
);
int wvsprintf(
LPTSTR lpOutput,
LPCTSTR lpFormat,
va_list argList
);
Services
Services are server processes. They can be linked to service table entries. More information is available at http://premium.microsoft.com/msdn/library/sdkdoc/services_0ofn.htm.
There are these structures:
typedef struct _ENUM_SERVICE_STATUS{
LPTSTR lpServiceName;
LPTSTR lpDisplayName;
SERVICE_STATUS serviceStatus;
} ENUM_SERVICE_STATUS, *LPENUM_SERVICE_STATUS;
typedef struct _QUERY_SERVICE_CONFIG{
DWORD dwServiceType;
DWORD dwStartType;
DWORD dwErrorControl;
LPTSTR lpBinaryPathNAme;
LPTSTR lpLoadOrderGroup;
DWORD dwTagIs;
LPTSTR lpDependencxies;
LPTSTR lpSErviceStartName;
LPTSTR lpDisplayNAme;
} QUERY_SERVICE_CONFIG, LPQUERY_SERVICE_CONFIG;
typedef struct QUERY_SERVICE_LOCK_STATUS{
DWORD fIslocked;
LPTSTR lpLockOwner;
DWORD dwLockDuration;
} QUERY_SERVICE_LOCK_STATUS, *LPQUERY_SERVICE_LOCK_STATUS;
typedef struct _SC_ACTION{
SC_ACTION_TYPE type;
DWORD delay;
} SC_ACTION, *LPSC_ACTION;
typedef struct _SERVICE_DESCRIPTION{
LPTSTR lpDescription;
} SERVICE_DESCRIPTION *LPSERVICE_DESCRIPTION;
typedef struct _SERVICE_FAILURE_ACTIONS{
DWORD dwResetPeriod;
LPTSTR lpRebootMsg;
LPTSTR lpCommand;
DWORD cActions;
SC_ACTION *lpsaActions;
} SERVICE_FAILURE_ACTIONS, *LPSERVICE_FAILURE_ACTIONS;
typedef struct _SERVICE_STATUS {
DWORD dwServiceType;
DWCurrentState;
DWORD dwControlsAccepted;
DWORD dwWin32ExitCode;
DWORD dwServiecSpecificExitCode;
DWORD dwCheckPoint;
DWORD dwWaitHint;
} SERVICE_STATUS, *LPSERVICE_STATUS;
typedef struct _SERVICE_TABLE_ENTRY{
LPTSTR lpServiceNAme;
LPSERVICE_MAIN_FUNCTION lpServiceProc;
} LPSERVICE_TABLE_ENTRY, *LPSERVICE_TABLE_ENTRY;
These functions have to do with Services.
BOOL ChangeServiceConfig{
SC_HANDLE hService,
DWORD dwServiceType,
DWORD dwStartType,
DWORD dwErrorControl,
LPCTSTR lpBinaryPathName,
LPCTSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPCTSTR lpDependencies,
LPCTSTR lpServiceStartName,
LPCTSTR lpPassword,
LPCTSTR lpDisplayName
);
BOOL ChangeServiceConfig2(
SC_HANDLE hService,
DWORD dwInfoLevel,
LPVOID lpInfo
);
BOOL CloseServiceHandle(
SC_HANDLE hSCObject
);
BOOL ControlService(
SC_HANDLE hSErvice,
DWORD dwControl,
LPSERVICE_STATUS,
);
SC_HANDLE CreateService(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
LPCTSTR lpDisplayName,
DWORD dwDesiredAccess,
DWORD dwServiceType,
DWORD dwStartType,
DWORD dwErrorControl,
LPCTSTR lpBinaryPathName,
LPCTSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPCTSTR lpDependencies,
LPCTSTR lpServiceStartNAme,
LPCTSTR lpPassword
);
BOOL DeleteService(
SC_HANDLE hService
);
BOOL EnumDependentServices(
SC_HANDLE,
DWORD dwServiceState,
LPENUM_SERVICE_STATUS lpServices,
DWORD cbBuffSize,
LPDWORD pcbBytesNeeded,
LPDWORD lpServicesReturned
);
BOOL EnumServicesStatus(
SC_HANDLE hSCManager,
DWORD dwServiceType,
DWORD dwServiceType,
LPENUM_SERVICE_STATUS lpServices,
DWORD cbBuffSize,
LPDWORD pcbBytesNeeded,
LPDWORD lpServicesReturned,
LPDWORD lpResumeHandle
);
BOOL GetServiceDisplayName(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
LPTSTR lpDisplayName,
LPDWORD lpcchBuffer
);
BOOL GetServiceKeyName(
SC_HANDLE hSCManager,
LPCTSTR lpDisplayName,
LPTSTR lpServiceName,
LPDWORD lpcchBuffer
);
VOID WINAPI Handler{
DWORD
);
SC_LOCK LockServiceDatabase(
SC_HANDLE hSCManager
);
BOOL NotifyBootConfigStatus(
BOOL bootAcceptable
);
SC_HANDLE OpenSCManager(
LPCTSTR lpMachineName,
LPCTSTR lpDatabaseName,
DWORD dwDesiredAccess
);
SC_HANDLE OpenService(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
DWORD dwDesiredAccess
);
BOOL QueryServiceConfig(
SC_HANDLE hService,
LPQUERY_SERVICE_CONFIG lpServiceConfig,
DWORD cbBufSize,
LPDWORD pcbBytesNeeded
);
BOOL QueryServiceConfig2(
SC_HANDLE hService,
DWORD dwInfoLevel,
LPBYTE lpBuffer,
DWORD cbBufSize,
LPDWORD pcbBytesNeeded
};
BOOL QueryServiceLockStatus(
SC_HANDLE hSCManager,
LPQUERY_SERVICE_LOCK_STATUS lpLockStatus,
DWORD cbBufSize,
LPDWORD pcbBytesNeeded
);
BOOL QueryServiceObjectSecurity(
SC_HANDLE hService,
SECURITY_INFORMATION dwSecurityInformation,
PSECURITY_DESCRIPTOR lpSecurityDescriptor,
DWORD cbBufSize,
LPDWORD pcbBytesNeeded
);
BOOL QueryServiceStatus(
SC_HANDLE hService,
LPSERVICE_STATUS lpServiceStatus
);
SERVICE_STATUS_REQUEST RegisterServiceCtrlHandler{
LPCTSTR lpServiceName,
LPHANDLER_FUNCTION lpHandlerProc
};
VOID WINAPI ServiceMain(
DWORD dwArgc,
LPTSTR *lpszArgvc
);
BOOL SetServiceBits(
SERVICE_STATUS_HANDLE hServiceStatus,
DWORD dwServiceBits,
BOOL bSetBitsOn,
BOOL bUpdateImmediately
);
SetServiceObjectSecurity(
SC_HANDLE hService,
SECURITY_INFORMATION dwSecurityInfo,
PSECURITY_DESCRIPTOR lpSecurityDescriptor
);
BOOL SetServiceStatus(
SERVICE_STATUS_HANDLE hService,
LPSERVICE_STATUS lpServiceStatus
);
BOOL StartService(
SC_HANDLE hService,
DWORD dwNumServiceArgs,
LPCTSTR *lpServiceArgVectors
);
BOOL StartServiceCtrlDispatcher(
LPSERVICE_TABLE_ENTRY lpServiceStartTable
);
BOOL UnlockServiceDatabase(
SC_LOCK sCLock
};
Shutdown
A number of functions have to do with System Shutdown. This from http://premium.microsoft.com/msdn/library/sdkdoc/winclass_1qcz.htm.
BOOL AbortSystemShutdown(
LPTSTR lpMachineNAme
);
BOOL ExitWindows(
DWORD dwReserved,
UINT uReserved
);
BOOL ExitWindowsEx(
UINt uFlags,
DWORD dwReserved
);
BOOL InitiateSystemShutdown(
LPTSTR lpMachineName,
LPTSTR lpMessage,
DWORD dwTimeout,
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown
);
Security
Security on NT is based on security privileges. http://premium.microsoft.com/msdn/library/sdkdoc/accctrl_42pf.htm.
These structures are with security: < A HREF="http://premium.microsoft.com/msdn/library/sdkdoc/accctrl_471v.htm">http://premium.microsoft.com/msdn/library/sdkdoc/accctrl_471v.htm
typedef DWORD ACCESS_MASK;
typedef struct _ACE{
} ACE;
tpedef struct _ACE_HEADER{
BYTE aceType;
BYTE aceFlags;
WORD aceSize;
} ACE_HEADER
typedef struct _ACL{
BYTE aclRevision;
BYTE sbzl;
WORD aclSize;
WORD aceCount;
WORD sbz2;
} ACL;
typedef struct _ACTRL_ALIST{
ULONG cEntries;
PACTRL_PROPERTY_ENTRY pPropertyAccessList
} ACTRL_ACCESS, PACTRL_ACCESS;
tpedef struct _ACTRL_ACCESS_ENTRY {
TRUSTEE trustee;
ULONG fAccessFlags;
ACCESS_RIGHTS access;
ACCESS_RIGHTS provSpecificAddress;
INHERIT_FLAGS inheritance;
LPCTSTR lpInheritProperty;
}
typedef struct _ACTRL_ACCESS_ENTRY_LIST {
ULONG cEntries;
PACTRL_ACCESS_ENTRY pAccessList;
} ACTRL_ACCESS_ENTRY_LIST, *PACTRL_ACCESS_ENTRY_LIST;
typedef struct ACTRL_ACCESS_INFO {
ULONG fAccessPermission;
LPTSTR lpAccessPermissionName;
} ACTRL_ACCESS_INFO, *PACTRL_ACCESS_INFO;
typedef struct _ACTRL_AUDIT {
ULONG cEntries;
PACTRL_PROPERTY_ENTRY pPropertyAccessList;
} ACTRL_AUDIT, *PACTRL_AUDIT;
typedef struct _ACTRL_OVERLAPPED {
ULONG reserved1;
ULONG reserved2;
HANDLE hEvent;
} ACTRL_OVERLAPPED, *PACTRL_OVERLAPPED;
typedef struct _ACTRL_PROPERTY_ENTRY{
LPCTSTR lpProperty;
PACTRL_ACCESS_ENTRY_LIST pAccessEntryList;
ULONG fListFlags;
} ACTRL_PROPERTY_ENTRY, *PACTRL_PROPERTY_ENTRY;
typedef LARGE_INTEGER LUID;
typedef struct _LUID_AND_ATTRIBUTES{
LUID luid;
DWORD attributes;
} LUID_AND_ATTRIBUTES;
typedef struct _PRIVILEGE_SET{
DWORD privilegeCount;
DWORD control;
LUID_AND_ATTRIBUTES privilege[ANYSIZE_ARAY]
} PRIVILEGE_SET;
typedef struct _SECURITY_ATTRIBUTES{
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES;
typedef PVOID PSECURITY_DESCRIPTOR;
typedef DWORD SECURITY_INFORMATION;
typedef struct _SID_AND_ATTRIBUTES{
PSID sid;
DWORD attributes;
} SID_AND_ATTRIBUTES;
typedef struct _SID_IDENTIFIER_AUTHORITY{
BYTE Value[6];
} SID_IDENTIFIER_AUTHORITY;
typedef PVOID PSID;
typedef struct _TOKEN_CONTROL{
LUID tokenId;
LUID authenticationId;
LUID modifiedId;
TOKEN_SOURCE tokenSource;
} TOKEN_CONTROL;
typedef struct _TOKEN_DEFAULT_DACL {
PACL defaultDacl;
} TOKEN_DEFAULT_DACL;
typedef struct _TOKEN_GROUPS {
DWORD groupCount;
SID_AND_ATTRIBUTES groups[ANYSIZE_ARRAY];
} TOKENGROUPS;
typedef struct _TOKEN_OWNER {
PSID owner;
} TOKEN_OWNER;
typedef struct _TOKEN_PRIMARY_GROUP {
PSID primaryGroup;
} TOKEN_PRIMARY_GROUP;
typedef struct _TOKEN_PRIVILEGES{
DWORD privilegeCount;
LUID_AND_ATTRIBUTES privileges[ANYSIZE_ARRAY]
} TOKEN_PRIVILEGES;
typedef struct _TOKEN_SOURCE {
Char sourcename[8];
LUID sourceIdentifier;
} TOKEN_SOURCE;
typedef struct _TOKEN_STATISTICS {
LUID tokenId;
LUID authenticationId;
LARGE_INTEGER expirationTime;
TOKEN_TYPE tokenType;
SECURITY_IMPERSONATION_LEVEL impersonationLevel;
DWORD dynamicCharged;
DWORD dynamicAvailable;
DWORD groupCount;
DWORD privilegeCount;
LUID modifiedId;
} TOKEN_STATISTICS;
typedef struct _TOKEN_USER {
SID_AND_ATTRIBUTES user;
} TOKEN_USER;
typedef struct _TRUSTEE {
PTRUSTEE pMultipleTrustee;
MULTIPLE_TRUSTEE_OPERATION multipleTrusteeOperation;
TRUSTEE_FORM trusteeForm;
TRUSTEE_TYPE trusteeType;
LPTSTR ptstrName;
} TRUSTEE;
typedef struct TRUSTEE_ACCESS {
LPTSTR lpProperty;
ACCESS_RIGHTS access;
ULONG fAccessFlags;
ULONG fReturnedAccess;
} TRUSTEE_ACCESS, *PTRUSTEE_ACCESS;
typedef enum _TRUSTEE_FORM {
TRUSTEE_IS_SID,
TRUSTEE_IS_NAME
} TRUSTEE_FORM;
Here are some security functions:http://premium.microsoft.com/msdn/library/sdkdoc/accctrl_6cmr.htm
BOOL AllocateLocallyUniqueId(
PLUID luid
);
BOOL LookupPrivilegeDisplayName{
LPCTSTR lpSystemName,
LPCTSTR lpName,
LPTSTR lpDisplayName,
LPDWORD cbDisplayName,
LPDWORD lpLanguageId
};
BOOL LookupPrivilegeName(
LPCTSTR lpSystemName
PLUID lpLuid,
LPTSTR lpName,
LPDWORD cbName
);
BOOL LookupPrivilegeValue(
LPCTSTR lpSystemName,
LPCTSTR lpName,
PLUID
);
Access Tokens:
BOOL SetThreadToken(
PHANDLE thread,
HANDLE token
);
BOOL DuplicateTokenEx(
HANDLe hExistingToken,
DWORD dwDesiredAccess,
LPSECURITY_ATTRIBUTES lpTokenAttributes,
SECURITY_IMPERSONATION_LEVEL impersonationLevel,
TOKEN_TYPE tokenType,
PHANDLE phNewToken
);
BOOL AdjustTokenGroups(
HANDLE tokenHandle,
BOOL resetToDefault,
PTOKEN_GROUPS newState,
DWORD bufferLength,
PTOKEN_GROUPS previousState,
PDWORD returnLength
);
BOOL AdjustTokenPrivileges(
HANDLE tokenHandle,
BOOL disableAllPrivileges
PTOKEN_PRIVILEGES newState,
DWORD bufferLength,
PTOKEN_PRIVILEGES previousState,
PDWORD returnLength
);
BOOL DuplicateToken(
HANDLE existingTokenHandle,
SECURITY_IMPERSONATION_LEVEL impersonationLevel,
PHANDLE duplicateTokenHandle
);
BOOL GetTokenInformation(
HANDLE tokenHandle,
TOKEN_INFORMATION_CLASS tokenInformationClass
LPVOID tokenInformation,
DWORD tokenInformationLength,
PDWORD returnLength
);
BOOL OpenProcessToken(
HANDLE processHandle,
DWORD desiredAccess,
PHANDLE tokenHandle
);
BOOL OpenThreadToken(
HANDLE threadHandle,
DWORD desiredAccess,
BOOL openAsSelf,
PHANDLE tokenHandle
);
BOOL SetTokenInformation(
HANDLe tokenHandle,
TOKEN_INFORMATION_CLASS tokenInformationClass,
LPVOID tokenInformation,
DWORD tokenInformationLength
);
Security Identifiers (SIDs)
BOOL AllocateAndInitializeSid(
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
BYTE nSubAuthorityCount,
DWORD dwSubAuthority0,
DWORD dwSubAuthority1,
DWORD dwSubAuthority2,
DWORD dwSubAuthority3,
DWORD dwSubAuthority4,
DWORD dwSubAuthority5,
DWORD dwSubAuthority6,
DWORD dwSubAuthority7,
PSID *pSId
);
BOOL CopySid(
DWORD nDestinationSidLength,
PSID pDestinationSid,
PSID pSourceSid
);
BOOL EqualPrefixSid(
PSID pSid1,
PSID pSid2
);
BOOL EqualSid(
PSID pSid1,
PSID pSid2
);
PVOID FreeSid(
PSID pSid
);
DWORD GetLengthSid(
PSID pSid
);
PSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority(
PSID pSid
);
DWORD GetSidLengthRequired(
UCHAR nSubAuthorityCount
);
PDWORD GetSidSubAuthority(
PSID pSid,
DWORD nSubAuthority
);
PUCHAR GetSidSubAuthorityCount(
psid PsID
);
BOOL InitializeSid(
PSID pSid,
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
BYTE nSubAuthorityCount
);
BOOL IsValidSid(
PSID pSid
);
BOOL LookupAccountName(
LPCTSTR lpSystemName,
LPCTSTR lpAccountName,
PSID pSid,
LPDWORD cbSid,
LPTSTR referencedDomainName,
LPDWORD cbReferencedDomainName,
PSID_NAME_USE peUse
);
BOOL LookupAccountSid(
LPCTSTR lpSystemName,
PSID pSid,
LPTSTR name,
LPDWORD cnName,
LPTSTR referencedDomainName,
LPDWORD cbReferencedDomainName,
OSID_NAME_USE peUse
);
Security Descriptor:
DWORD CancelOverlappedAccess(
PACTRL_OVERLAPPED pOverlapped
);
DWORD ConvertAccessToSecurityDescriptor(
PACTRL_ACCESS pAccessList,
PACTRL_AUDIT pAuditList,
LPCTSTR lpOwner,
LPCTSTR lpGroup,
PSECURITY_DESCRIPTOR *ppSecDescriptor
);
DWORD ConvertSecurityDescriptorToAccess(
HANDLE hObject,
SE_OBJECT_TYPE objectype,
PSECURITY_DESCRIPTION pSecDescriptor,
PACTRL_ACCESS *ppAccessList,
PACTRL_AUDIT *ppAuditList,
LPTSTR *lppOwner,
LPTSTR *lppGroup
);
DWORD ConverSecurityDescriptorToAccessNamed(
LPCTSTR lpObject,
SE_OBJECT_TYPE objectType,
PSECURITY_DESCRIPTOR pSecDescriptor,
PACTRL_ACCESS *ppAccessList,
PACTRL_AUDIT *ppAuditList,
LPTSTR *lppOwner,
LPTSTR *lppGroup
);
DWORD GetNamedSecurityInfoEx(
LPCTSTR lpObject,
SE_OBJECT_TYPE objectType,
SECURITY_INFORMATION securityInfo,
LPCTSTR lpProvider,
LPCTSTR lpProperty,
PACTRL_ACCESS *ppAccessList,
PACTRL_AUDIT *ppAuditList,
LPTSTR *lppOwner,
LPTSTR *lppGroup
);
DWORD GetOverlappedAccessResults(
PACTRL_OVERLAPPED pOverLapped,
BOOL fWaitForCompletion,
PDWORD pResult,
PULONG pcItemsProcessed
);
DWORD GetSecurityInfoEx(
HANDLE hObject,
SE_OBJECT_TYPE objectType,
SECURITY_INFORMATION securityInfo,
LPCTSTR lpProvider,
LPCTSTR lpProperty,
PACTRL_ACCESS *ppAccessList,
PACTRL_AUDIT *ppAuditList,
LPTSTR *lppOwner,
LPTSTR *lppGroup
);
SetNamedSecurityInfoEx(
LPCTSTR lpObject,
SE_OBJECT_TYPE objectType,
SECURITY_INFORMATION, securityInfo,
LPCTSTR lpProvider,
PACTRL_ACCESS pAccessList,
PACTRL_AUDIT pAuditList,
LPTSTR lpOwner,
LPTSTR lpGroup,
PACTRL_OVERLAPPED pOverlapped
);
DWORD SetSecurityInfoEx(
HANDLE hObject,
SE_OBJECT_TYPE objectType,
SECURITY_INFORMATION, securityInfo,
LPCTSTR lpProvider,
PACTRL_ACCESS pAccessList,
PACTRL_AUDIT pAuditList,
LPTSTR lpOwner,
LPTSTR lpGroup,
PACTRL_OVERLAPPED pOverlapped
);
BOOL SetSecurityDescriptorControl(
PSECURITY_DESCRIPTOR pSecurityDescriptor,
SECURITY_DESCRIPTOR_CONTROL controlBitsOfInterest,
SECURITY_DESRIPTOR_CONTROL controlBitsToSet
);
BOOL GetSecurityDescriptorControl(
PSECURITY_DESCRIPTOR pSecurityDescription,
PSECURITY_DESCRIPTOR_CONTROL pControl,
LPDWORD lpdwRevision
);
Access Control Lists:
DWORD SetEntriesInAccessList(
ULONG cEntries,
PACTRL_ACCESS_ENTRY pAccessEntryList,
ACCESS_MODE accessMode,
LPCTSTR lpProperty,
PACTRL_ACCESS pOldList,
PACTRL_ACCESS *ppNewList
);
DWORD SetEntriesInAuditList(
ULONG cEntries,
PACTRL_ACCESS_ENTRY pAccessEntryList,
ACCESS_MODE accessMode,
LPCTSTR plProperty,
PACTRL_AUDIT pOldList,
PACTRL_AUDIT *ppNewList
);
VOID BuildTrusteeWithName (
PTRUSTEE pTrustee,
LPTSTR pNAme
);
VOID BuildTrusteeWithSid(
PTRUSTEE pTrustee,
PSID pSid
);
TRUSTEE_FORM GetTrusteeForm(
PTRUSTEE pTrustee
);
LPTSTR GetTrusteeName(
PTRUSTEE pTrustee,
);
TRUSTEE_TYPE GetTrusteeType(
PTRUSTEE pTrustee
);
DWORD TrusteeAccessToObject(
LPCTSTR lpObject,
SE_OBJECT_TYPE objectType,
LPCTSTR lpProvider,
PTRUSTEE pTrustee,
ULONG cEntries,
PTRUSTEE_ACCESS pTrustedAccess
);
The operating system offers access to hardware graphics acceleration. DirectX 5 has many multimedia features.
I have had to reboot this operating system.
Thanks! Have a nice day! Please let me know if there are inaccuracies in this document.
Here are some other links to Win32 Programming Links: http://www.tomco.net/~raf/win32.html
Microsoft Access and other trademarks are property of Microsoft. © 1997-1998 Finlayson Consulting All rights reserved.