WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
Classes | Macros | Typedefs | Functions
Win.h File Reference

Integrates WinStd classes with Microsoft Windows API. More...

#include "Common.h"
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  winstd::win_handle< INVALID >
 Windows HANDLE wrapper class. More...
 
class  winstd::library
 Module handle wrapper. More...
 
struct  winstd::UnmapViewOfFile_delete< _Ty >
 Deleter for unique_ptr using UnmapViewOfFile. More...
 
struct  winstd::UnmapViewOfFile_delete< _Ty[]>
 Deleter for unique_ptr to array of unknown size using UnmapViewOfFile. More...
 
class  winstd::critical_section
 Critical section wrapper. More...
 
class  winstd::find_file
 Find-file handle wrapper. More...
 
class  winstd::heap
 Heap handle wrapper. More...
 
class  winstd::heap_allocator< _Ty >
 HeapAlloc allocator. More...
 
struct  winstd::heap_allocator< _Ty >::rebind< _Other >
 A structure that enables an allocator for objects of one type to allocate storage for objects of another type. More...
 
class  winstd::actctx_activator
 Activates given activation context in constructor and deactivates it in destructor. More...
 
class  winstd::user_impersonator
 Lets the calling thread impersonate the security context of a logged-on user. More...
 
class  winstd::console_ctrl_handler
 Console control handler stack management. More...
 
class  winstd::vmemory
 Memory in virtual address space of a process handle wrapper. More...
 
class  winstd::reg_key
 Registry key wrapper class. More...
 
class  winstd::security_id
 SID wrapper class. More...
 
class  winstd::process_information
 PROCESS_INFORMATION struct wrapper. More...
 
class  winstd::event_log
 Event log handle wrapper. More...
 

Macros

#define GuidToString   GuidToStringA
 Formats GUID and stores it in a std::wstring string. More...
 
#define StringToGuid   StringToGuidA
 Parses string with GUID and stores it to GUID. More...
 

Typedefs

typedef win_handle< NULL > winstd::process
 Process handle wrapper. More...
 
typedef win_handle< NULL > winstd::thread
 Thread handle wrapper. More...
 
typedef win_handle< INVALID_HANDLE_VALUE > winstd::process_snapshot
 Process snapshot handle wrapper. More...
 
typedef win_handle< INVALID_HANDLE_VALUE > winstd::file
 File handle wrapper. More...
 
typedef win_handle< NULL > winstd::file_mapping
 File mapping. More...
 
typedef win_handle< NULL > winstd::event
 Event handle wrapper. More...
 

Functions

template<class _Traits , class _Ax >
static DWORD GetModuleFileNameA (HMODULE hModule, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
 Retrieves the fully qualified path for the file that contains the specified module and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static DWORD GetModuleFileNameW (HMODULE hModule, std::basic_string< wchar_t, _Traits, _Ax > &sValue) noexcept
 Retrieves the fully qualified path for the file that contains the specified module and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static int GetWindowTextA (HWND hWnd, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
 Copies the text of the specified window's title bar (if it has one) into a std::wstring string. More...
 
template<class _Traits , class _Ax >
static int GetWindowTextW (HWND hWnd, std::basic_string< wchar_t, _Traits, _Ax > &sValue) noexcept
 Copies the text of the specified window's title bar (if it has one) into a std::wstring string. More...
 
template<class _Ty , class _Ax >
static BOOL GetFileVersionInfoA (LPCSTR lptstrFilename, __reserved DWORD dwHandle, std::vector< _Ty, _Ax > &aValue) noexcept
 Retrieves version information for the specified file and stores it in a std::vector buffer. More...
 
template<class _Ty , class _Ax >
static BOOL GetFileVersionInfoW (LPCWSTR lptstrFilename, __reserved DWORD dwHandle, std::vector< _Ty, _Ax > &aValue) noexcept
 Retrieves version information for the specified file and stores it in a std::vector buffer. More...
 
template<class _Traits , class _Ax >
static DWORD ExpandEnvironmentStringsA (LPCSTR lpSrc, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
 Expands environment-variable strings, replaces them with the values defined for the current user, and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static DWORD ExpandEnvironmentStringsW (LPCWSTR lpSrc, std::basic_string< wchar_t, _Traits, _Ax > &sValue) noexcept
 Expands environment-variable strings, replaces them with the values defined for the current user, and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static VOID GuidToStringA (LPCGUID lpGuid, std::basic_string< char, _Traits, _Ax > &str) noexcept
 Formats GUID and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static VOID GuidToStringW (LPCGUID lpGuid, std::basic_string< wchar_t, _Traits, _Ax > &str) noexcept
 Formats GUID and stores it in a std::wstring string. More...
 
static BOOL StringToGuidA (LPCSTR lpszGuid, LPGUID lpGuid, LPCSTR *lpszGuidEnd=NULL) noexcept
 Parses string with GUID and stores it to GUID. More...
 
static BOOL StringToGuidW (LPCWSTR lpszGuid, LPGUID lpGuid, LPCWSTR *lpszGuidEnd=NULL) noexcept
 Parses string with GUID and stores it to GUID. More...
 
template<class _Traits , class _Ax >
static LSTATUS RegQueryStringValue (HKEY hReg, LPCSTR pszName, std::basic_string< char, _Traits, _Ax > &sValue) noexcept
 Queries for a string value in the registry and stores it in a std::string string. More...
 
template<class _Traits , class _Ax >
static LSTATUS RegQueryStringValue (HKEY hReg, LPCWSTR pszName, std::basic_string< wchar_t, _Traits, _Ax > &sValue) noexcept
 Queries for a string value in the registry and stores it in a std::wstring string. More...
 
template<class _Ty , class _Ax >
static LSTATUS RegQueryValueExA (HKEY hKey, LPCSTR lpValueName, __reserved LPDWORD lpReserved, LPDWORD lpType, std::vector< _Ty, _Ax > &aData) noexcept
 Retrieves the type and data for the specified value name associated with an open registry key and stores the data in a std::vector buffer. More...
 
template<class _Ty , class _Ax >
static LSTATUS RegQueryValueExW (HKEY hKey, LPCWSTR lpValueName, __reserved LPDWORD lpReserved, LPDWORD lpType, std::vector< _Ty, _Ax > &aData) noexcept
 Retrieves the type and data for the specified value name associated with an open registry key and stores the data in a std::vector buffer. More...
 
template<class _Traits , class _Ax >
static LSTATUS RegLoadMUIStringA (HKEY hKey, LPCSTR pszValue, std::basic_string< char, _Traits, _Ax > &sOut, DWORD Flags, LPCSTR pszDirectory) noexcept
 Loads the specified string from the specified key and subkey, and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static LSTATUS RegLoadMUIStringW (HKEY hKey, LPCWSTR pszValue, std::basic_string< wchar_t, _Traits, _Ax > &sOut, DWORD Flags, LPCWSTR pszDirectory) noexcept
 Loads the specified string from the specified key and subkey, and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static int WideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::basic_string< char, _Traits, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set. More...
 
template<class _Ax >
static int WideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::vector< char, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set. More...
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int WideCharToMultiByte (UINT CodePage, DWORD dwFlags, std::basic_string< wchar_t, _Traits1, _Ax1 > sWideCharStr, std::basic_string< char, _Traits2, _Ax2 > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set. More...
 
template<class _Traits , class _Ax >
static int SecureWideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::basic_string< char, _Traits, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set. More...
 
template<class _Ax >
static int SecureWideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::vector< char, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set. More...
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int SecureWideCharToMultiByte (UINT CodePage, DWORD dwFlags, std::basic_string< wchar_t, _Traits1, _Ax1 > sWideCharStr, std::basic_string< char, _Traits2, _Ax2 > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set. More...
 
template<class _Traits , class _Ax >
static int MultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::basic_string< wchar_t, _Traits, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. More...
 
template<class _Ax >
static int MultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::vector< wchar_t, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set. More...
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int MultiByteToWideChar (UINT CodePage, DWORD dwFlags, const std::basic_string< char, _Traits1, _Ax1 > &sMultiByteStr, std::basic_string< wchar_t, _Traits2, _Ax2 > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. More...
 
template<class _Traits , class _Ax >
static int SecureMultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::basic_string< wchar_t, _Traits, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. More...
 
template<class _Ax >
static int SecureMultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::vector< wchar_t, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set. More...
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int SecureMultiByteToWideChar (UINT CodePage, DWORD dwFlags, const std::basic_string< char, _Traits1, _Ax1 > &sMultiByteStr, std::basic_string< wchar_t, _Traits2, _Ax2 > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. More...
 
template<class _Traits , class _Ax >
static int NormalizeString (NORM_FORM NormForm, LPCWSTR lpSrcString, int cwSrcLength, std::basic_string< wchar_t, _Traits, _Ax > &sDstString) noexcept
 Normalizes characters of a text string according to Unicode 4.0 TR#15. More...
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int NormalizeString (NORM_FORM NormForm, const std::basic_string< wchar_t, _Traits1, _Ax1 > &sSrcString, std::basic_string< wchar_t, _Traits2, _Ax2 > &sDstString) noexcept
 Normalizes characters of a text string according to Unicode 4.0 TR#15. More...
 
template<class _Traits , class _Ax >
static int WINAPI LoadStringA (HINSTANCE hInstance, UINT uID, std::basic_string< char, _Traits, _Ax > &sBuffer) noexcept
 Loads a string resource from the executable file associated with a specified module. More...
 
template<class _Traits , class _Ax >
static int WINAPI LoadStringW (HINSTANCE hInstance, UINT uID, std::basic_string< wchar_t, _Traits, _Ax > &sBuffer) noexcept
 Loads a string resource from the executable file associated with a specified module. More...
 
static VOID OutputDebugStrV (LPCSTR lpOutputString, va_list arg) noexcept
 Formats and sends a string to the debugger for display. More...
 
static VOID OutputDebugStrV (LPCWSTR lpOutputString, va_list arg) noexcept
 Formats and sends a string to the debugger for display. More...
 
static VOID OutputDebugStr (LPCSTR lpOutputString,...) noexcept
 Formats and sends a string to the debugger for display. More...
 
static VOID OutputDebugStr (LPCWSTR lpOutputString,...) noexcept
 Formats and sends a string to the debugger for display. More...
 
template<class _Traits , class _Ax >
static int GetDateFormatA (LCID Locale, DWORD dwFlags, const SYSTEMTIME *lpDate, LPCSTR lpFormat, std::basic_string< char, _Traits, _Ax > &sDate) noexcept
 Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or the local system date. More...
 
template<class _Traits , class _Ax >
static int GetDateFormatW (LCID Locale, DWORD dwFlags, const SYSTEMTIME *lpDate, LPCWSTR lpFormat, std::basic_string< wchar_t, _Traits, _Ax > &sDate) noexcept
 Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or the local system date. More...
 
template<class _Traits , class _Ax >
static BOOL LookupAccountSidA (LPCSTR lpSystemName, PSID lpSid, std::basic_string< char, _Traits, _Ax > *sName, std::basic_string< char, _Traits, _Ax > *sReferencedDomainName, PSID_NAME_USE peUse) noexcept
 Retrieves the name of the account for this SID and the name of the first domain on which this SID is found. More...
 
template<class _Traits , class _Ax >
static BOOL LookupAccountSidW (LPCWSTR lpSystemName, PSID lpSid, std::basic_string< wchar_t, _Traits, _Ax > *sName, std::basic_string< wchar_t, _Traits, _Ax > *sReferencedDomainName, PSID_NAME_USE peUse) noexcept
 Retrieves the name of the account for this SID and the name of the first domain on which this SID is found. More...
 
template<class _Ty >
static BOOL GetTokenInformation (HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, std::unique_ptr< _Ty > &TokenInformation) noexcept
 Retrieves a specified type of information about an access token. The calling process must have appropriate access rights to obtain the information. More...
 
template<class _Traits , class _Ax >
static BOOL QueryFullProcessImageNameA (HANDLE hProcess, DWORD dwFlags, std::basic_string< char, _Traits, _Ax > &sExeName)
 Retrieves the full name of the executable image for the specified process. More...
 
template<class _Traits , class _Ax >
static BOOL QueryFullProcessImageNameW (HANDLE hProcess, DWORD dwFlags, std::basic_string< wchar_t, _Traits, _Ax > &sExeName)
 Retrieves the full name of the executable image for the specified process. More...
 
static LSTATUS RegCreateKeyExA (HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, DWORD dwOptions, REGSAM samDesired, CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes, winstd::reg_key &result, LPDWORD lpdwDisposition)
 Creates the specified registry key. If the key already exists, the function opens it. More...
 
static LSTATUS RegCreateKeyExW (HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions, REGSAM samDesired, CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes, winstd::reg_key &result, LPDWORD lpdwDisposition)
 Creates the specified registry key. If the key already exists, the function opens it. More...
 
static LSTATUS RegOpenKeyExA (HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
 Opens the specified registry key. More...
 
static LSTATUS RegOpenKeyExW (HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, winstd::reg_key &result)
 Opens the specified registry key. More...
 

Detailed Description

Integrates WinStd classes with Microsoft Windows API.