Download Source Code

CWin32 Class Reference

Generic Windows functions. More...

#include <Win32.h>

List of all members.

Public Types

typedef CWin32::__WINDOWS_SERVICE_STATUS WINDOWS_SERVICE_STATUS
 Contains information about a Windows service.
typedef CWin32::__WINDOWS_SERVICE_STATUSLPWINDOWS_SERVICE_STATUS
 Contains information about a Windows service.

Public Member Functions

 CWin32 ()
 Constructor.
virtual ~CWin32 ()
 Destructor.

Static Public Member Functions

static BOOL PopupMenu (long x, long y, LPCTSTR pMenu, HWND hWnd, HMODULE hInstance, long lSub=-1)
 Shows a popup menu.
static BOOL ControlService (LPCTSTR pServiceName, DWORD dwControl, LPWINDOWS_SERVICE_STATUS pStatus=NULL)
 Executes specified command on named service.
static BOOL StartService (LPCTSTR pServiceName)
 Starts the specified service.
static HWND SearchWindow (LPCTSTR pClass, LPCTSTR pName, HWND hRoot=NULL, BOOL bChild=FALSE)
 Searches for a particular window, allows wild cards.
static const GUID * StringToGuid (GUID *pGuid, LPCTSTR pString)
 Converts a string GUID to binary form.
static LPCTSTR GuidToString (LPSTR pStr, const GUID *pGuid=NULL)
 Converts a binary GUID into string representation.
static BOOL GetWSAErrorMsg (LPSTR pMsg, DWORD err)
 Creates an error string for Windows Socket error codes.
static BOOL ShowError (HWND hParent, DWORD dwError, LPCTSTR pTitle, LPCTSTR pAdd=NULL, DWORD dwType=MB_OK|MB_ICONEXCLAMATION)
 Shows a dialog box displaying information about a Windows error.
static BOOL GetSystemErrorMsg (DWORD dwErr, LPSTR pMsg, LPCTSTR pTemplate=NULL)
 Returns information about a Windows or Socket error code.
static BOOL AutoComplete (HWND hTarget, DWORD dwFlags)
 Enables web address auto complete on the specified edit box.
static BOOL GetSysInfo (LPACTIVESYSPARAMS pAsp)
 Returns information about the system state.
static double GetCpuLoad ()
 Returns the current CPU load.
static BOOL SetTransparency (HWND hWnd, COLORREF rgbTransparent)
 Sets the transparency color key of a layerd window.
static BOOL SetTranslucency (HWND hWnd, DWORD dwTl)
 Sets the translucency of a window.
static DWORD GetIEVersion ()
 Returns the version of IE that is installed.
static BOOL RunModalLoop (HWND hWnd)
 Creates a modal loop.
static BOOL StartNewApp ()
 Starts a new instance of this application.
static BOOL Reboot ()
 Reboots Windows.
static BOOL ahtoudw (LPDWORD pdwNum, LPCTSTR pBuffer, BYTE ucBytes, BOOL bSkipInvalid=FALSE)
 Converts ASCII hex value to DWORD.
static BOOL RedrawWindow (HWND hWnd, const RECT *pRect=NULL, HRGN hRgn=NULL, UINT uFlags=RDW_ERASE|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN)
 Redraws the specified window.
static const GUID * Md5Hash (GUID *pGuid, LPVOID pBuf, DWORD dwSize)
 Quick way to create a GUID from a data buffer.
static const GUID * Md5Hash (GUID *pGuid, LPCTSTR pStr)
 Quick way to create a GUID from a string.

Classes

struct  __WINDOWS_SERVICE_STATUS
 Contains information about a Windows service. More...


Detailed Description

Generic Windows functions.

This class provides a few generic Windows functions. These are provided through static functions so there is no need to create an instance of this class.


Member Function Documentation

BOOL CWin32::ahtoudw LPDWORD  pdwNum,
LPCTSTR  pBuffer,
BYTE  ucBytes,
BOOL  bSkipInvalid = FALSE
[static]
 

Converts ASCII hex value to DWORD.

Parameters:
[in] pdwNum - Receives DWORD value
[in] pBuffer - Buffer containing ASCII hex string
[in] ucBytes - Bytes in pBuffer to convert
[in] bSkipInvalid - Non-zero to skip invalid characters
if bSkipInvalid is set to zero and an invalid character is found, the function aborts the conversion and returns zero.

Returns:
Non-zero if success
See also:

BOOL CWin32::AutoComplete HWND  hTarget,
DWORD  dwFlags
[static]
 

Enables web address auto complete on the specified edit box.

Parameters:
[in] hTarget - Edit box handle
[in] dwFlags - Auto complete flags
Returns:
Non-zero if success
See also:

BOOL CWin32::ControlService LPCTSTR  pServiceName,
DWORD  dwControl,
LPWINDOWS_SERVICE_STATUS  pStatus = NULL
[static]
 

Executes specified command on named service.

Parameters:
[in] pServiceName - Service name
[in] dwControl - Service control function
  • SERVICE_CONTROL_STOP - Stops the service
  • SERVICE_CONTROL_PAUSE - Pauses the service
  • SERVICE_CONTROL_CONTINUE - Continues a paused service
  • SERVICE_CONTROL_INTERROGATE - Retrieves service status information in pStatus.
  • SERVICE_CONTROL_SHUTDOWN - Function fails if this command is specified.
[in] pStatus - Receives the latest service status information. Can be NULL.
Returns:
Non-zero if success
See also:

BOOL CWin32::GetSysInfo LPACTIVESYSPARAMS  pAsp  )  [static]
 

Returns information about the system state.

Parameters:
[in] pAsp - Receives system state information
Returns:
Non-zero if success
See also:
ACTIVESYSPARAMS

BOOL CWin32::GetSystemErrorMsg DWORD  dwErr,
LPSTR  pMsg,
LPCTSTR  pTemplate = NULL
[static]
 

Returns information about a Windows or Socket error code.

Parameters:
[in] dwErr - Error code
[in] pMsg - Receives the error code string
[in] pTemplate - Template that defines the message format.
pTemplate is passed to wsprintf to format the error string. The default template is "%lu ( 0x%lX ) : %s".

Returns:
Non-zero if success
See also:

BOOL CWin32::GetWSAErrorMsg LPSTR  pMsg,
DWORD  err
[static]
 

Creates an error string for Windows Socket error codes.

Parameters:
[in] pMsg - Receives human readable error string
[in] err - Windows Socket error code
Returns:
Non-zero if valid socket error code.
See also:

LPCTSTR CWin32::GuidToString LPSTR  pStr,
const GUID *  pGuid = NULL
[static]
 

Converts a binary GUID into string representation.

Parameters:
[in] pStr - Receives GUID
[in] pGuid - Binary GUID
if pGuid is NULL, a unique GUID is returned in pStr generated by calling CoCreateGUID().

Returns:
Value in pStr or NULL if failure
See also:

static const GUID* CWin32::Md5Hash GUID *  pGuid,
LPCTSTR  pStr
[inline, static]
 

Quick way to create a GUID from a string.

Parameters:
[in] pGuid - Recieves the new GUID
[in] pStr - NULL terminated string to hash.
Returns:
Value in pGuid

static const GUID* CWin32::Md5Hash GUID *  pGuid,
LPVOID  pBuf,
DWORD  dwSize
[inline, static]
 

Quick way to create a GUID from a data buffer.

Parameters:
[in] pGuid - Receives the GUID
[in] pBuf - Buffer containing data to hash
[in] dwSize - Number of bytes in pBuf. If zero, a NULL terminated string is assumed.
Returns:
Value in pGuid

BOOL CWin32::PopupMenu long  x,
long  y,
LPCTSTR  pMenu,
HWND  hWnd,
HMODULE  hInstance,
long  lSub = -1
[static]
 

Shows a popup menu.

Parameters:
[in] x - Horizontal offset for popup menu
[in] y - Vertical offset for popup menu
[in] pMenu - Menu resource ID
[in] hWnd - Handle to window that receives the menu commands.
[in] hInstance - Application instance handle containing the popup menu resource.
[in] lSub - If >= 0, specifies the sub menu index to use.
Returns:
Non-zero if success
See also:

BOOL CWin32::Reboot  )  [static]
 

Reboots Windows.

Returns:
Non-zero if success

static BOOL CWin32::RedrawWindow HWND  hWnd,
const RECT *  pRect = NULL,
HRGN  hRgn = NULL,
UINT  uFlags = RDW_ERASE | RDW_INVALIDATE | RDW_ERASENOW | RDW_UPDATENOW | RDW_ALLCHILDREN
[inline, static]
 

Redraws the specified window.

Parameters:
[in] hWnd - Handle to window
[in] pRect - Area of window to redraw, NULL for all
[in] hRgn - Region of window to redraw, NULL for all
[in] uFlags - Redraw flags
Returns:
Non-zero if success
See also:

BOOL CWin32::RunModalLoop HWND  hWnd  )  [static]
 

Creates a modal loop.

Parameters:
[in] hWnd - Window handle
Returns:
Non-zero if success
See also:

HWND CWin32::SearchWindow LPCTSTR  pClass,
LPCTSTR  pName,
HWND  hRoot = NULL,
BOOL  bChild = FALSE
[static]
 

Searches for a particular window, allows wild cards.

Parameters:
[in] pClass - Class name to find or NULL for any
[in] pName - Window text to find or NULL for any
[in] hRoot - Root window, NULL for desktop
[in] bChild - Non-zero to search child windows
Note:
It would be nice to have a way to continue the search for other matching windows.
Returns:
Handle of first window found
See also:

BOOL CWin32::SetTranslucency HWND  hWnd,
DWORD  dwTl
[static]
 

Sets the translucency of a window.

Parameters:
[in] hWnd - Window handle
[in] dwTl - Level of translucency ( 0 - 255 )
Returns:
Non-zero if success
See also:

BOOL CWin32::SetTransparency HWND  hWnd,
COLORREF  rgbTransparent
[static]
 

Sets the transparency color key of a layerd window.

Parameters:
[in] hWnd - Window handle
[in] rgbTransparent - Transparent color key
Returns:
Non-zero if success
See also:

BOOL CWin32::ShowError HWND  hParent,
DWORD  dwError,
LPCTSTR  pTitle,
LPCTSTR  pAdd = NULL,
DWORD  dwType = MB_OK|MB_ICONEXCLAMATION
[static]
 

Shows a dialog box displaying information about a Windows error.

Parameters:
[in] hParent - Parent window for dialog box
[in] dwError - Windows or Socket error code.
[in] pTitle - Dialog box title
[in] pAdd - String to add to the end of the message.
[in] dwType - Type of dialog box to display
Returns:
Non-zero if success
See also:

BOOL CWin32::StartNewApp  )  [static]
 

Starts a new instance of this application.

Returns:
Non-zero if success

BOOL CWin32::StartService LPCTSTR  pServiceName  )  [static]
 

Starts the specified service.

Parameters:
[in] pServiceName - Name of service
Returns:
Non-zero if service was started
See also:

const GUID * CWin32::StringToGuid GUID *  pGuid,
LPCTSTR  pString
[static]
 

Converts a string GUID to binary form.

Parameters:
[in] pGuid - Buffer that receives GUID
[in] pString - String to convert
Warning:
Must match the exact format of XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX or function will fail.
Returns:
Value in pGuid or NULL if failure
See also:


The documentation for this class was generated from the following files:
  • inc/Win32.h
  • Win32.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL