├── lib32 ├── Ntdll.lib ├── UtilsDUS.lib ├── UtilsDUS.pdb ├── UtilsRUS.lib ├── UtilsRUS.pdb ├── UtilsWDK.lib └── vs2008 │ ├── Ntdll.lib │ ├── UtilsDUS.lib │ ├── UtilsDUS.pdb │ ├── UtilsRUS.lib │ └── UtilsRUS.pdb ├── lib64 ├── Ntdll.lib ├── UtilsDUS.lib ├── UtilsDUS.pdb ├── UtilsRUS.lib ├── UtilsRUS.pdb ├── UtilsWDK.lib └── vs2008 │ ├── Ntdll.lib │ ├── UtilsDUS.lib │ ├── UtilsDUS.pdb │ ├── UtilsRUS.lib │ └── UtilsRUS.pdb ├── libarm64 ├── UtilsDUS.lib ├── UtilsDUS.pdb ├── UtilsRUS.lib └── UtilsRUS.pdb ├── README.md ├── .gitignore ├── LICENSE └── inc ├── TToolTip.h ├── TStringConvert.h ├── afxres.h ├── TIniFile.h ├── TDropHelper.h ├── TAnchors.h └── Utils.h /lib32/Ntdll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/Ntdll.lib -------------------------------------------------------------------------------- /lib64/Ntdll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/Ntdll.lib -------------------------------------------------------------------------------- /lib32/UtilsDUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/UtilsDUS.lib -------------------------------------------------------------------------------- /lib32/UtilsDUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/UtilsDUS.pdb -------------------------------------------------------------------------------- /lib32/UtilsRUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/UtilsRUS.lib -------------------------------------------------------------------------------- /lib32/UtilsRUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/UtilsRUS.pdb -------------------------------------------------------------------------------- /lib32/UtilsWDK.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/UtilsWDK.lib -------------------------------------------------------------------------------- /lib64/UtilsDUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/UtilsDUS.lib -------------------------------------------------------------------------------- /lib64/UtilsDUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/UtilsDUS.pdb -------------------------------------------------------------------------------- /lib64/UtilsRUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/UtilsRUS.lib -------------------------------------------------------------------------------- /lib64/UtilsRUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/UtilsRUS.pdb -------------------------------------------------------------------------------- /lib64/UtilsWDK.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/UtilsWDK.lib -------------------------------------------------------------------------------- /libarm64/UtilsDUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/libarm64/UtilsDUS.lib -------------------------------------------------------------------------------- /libarm64/UtilsDUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/libarm64/UtilsDUS.pdb -------------------------------------------------------------------------------- /libarm64/UtilsRUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/libarm64/UtilsRUS.lib -------------------------------------------------------------------------------- /libarm64/UtilsRUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/libarm64/UtilsRUS.pdb -------------------------------------------------------------------------------- /lib32/vs2008/Ntdll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/vs2008/Ntdll.lib -------------------------------------------------------------------------------- /lib64/vs2008/Ntdll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/vs2008/Ntdll.lib -------------------------------------------------------------------------------- /lib32/vs2008/UtilsDUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/vs2008/UtilsDUS.lib -------------------------------------------------------------------------------- /lib32/vs2008/UtilsDUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/vs2008/UtilsDUS.pdb -------------------------------------------------------------------------------- /lib32/vs2008/UtilsRUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/vs2008/UtilsRUS.lib -------------------------------------------------------------------------------- /lib32/vs2008/UtilsRUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib32/vs2008/UtilsRUS.pdb -------------------------------------------------------------------------------- /lib64/vs2008/UtilsDUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/vs2008/UtilsDUS.lib -------------------------------------------------------------------------------- /lib64/vs2008/UtilsDUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/vs2008/UtilsDUS.pdb -------------------------------------------------------------------------------- /lib64/vs2008/UtilsRUS.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/vs2008/UtilsRUS.lib -------------------------------------------------------------------------------- /lib64/vs2008/UtilsRUS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ladislav-zezula/Aaa/HEAD/lib64/vs2008/UtilsRUS.pdb -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository contains a static libraries needed to build my other projects, namely FileTest. 2 | To use them, you need to create a directory structure like this: 3 | 4 | Your-Working-Folder 5 | +- Aaa 6 | +- FileTest 7 | 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Compiled Dynamic libraries 8 | *.so 9 | *.dylib 10 | *.dll 11 | 12 | # Compiled Static libraries 13 | *.lai 14 | *.la 15 | *.a 16 | 17 | # Executables 18 | *.exe 19 | *.out 20 | *.app 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ladislav Zezula 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /inc/TToolTip.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* TToolTip.h Copyright (c) Ladislav Zezula 2004 */ 3 | /*---------------------------------------------------------------------------*/ 4 | /* Header file which interfaces the class implementing a tooltip */ 5 | /*---------------------------------------------------------------------------*/ 6 | /* Date Ver Who Comment */ 7 | /* -------- ---- --- ------- */ 8 | /* 07.06.04 1.00 Lad The first version of TToolTip.h */ 9 | /*****************************************************************************/ 10 | 11 | #ifndef __TTOOLTIP_H__ 12 | #define __TTOOLTIP_H__ 13 | 14 | class TToolTip 15 | { 16 | public: 17 | 18 | // Constructor uses the handle to the window which will show the tooltips, 19 | // e.g. dialog box window. For a dialog, a good place to construct the 20 | // TToolTip object is the OnInitDialog method. 21 | TToolTip(HWND hParent); 22 | ~TToolTip(); 23 | 24 | // Adding tooltips for child windows and/or rectangles 25 | LRESULT AddTipForChild(HWND hWnd, UINT_PTR nIDString); 26 | LRESULT AddTipForChild(HWND hDlg, UINT nIDCtrl, UINT nIDString); 27 | LRESULT AddTipForRect(RECT & rect, UINT_PTR nIDString); 28 | 29 | // Configuring tooltip 30 | // void RemoveAll(); 31 | 32 | 33 | protected: 34 | 35 | HWND m_hParent; 36 | HWND m_hToolTip; 37 | UINT m_nIdCounter; 38 | }; 39 | 40 | #endif // __TTOOLTIP_H__ 41 | -------------------------------------------------------------------------------- /inc/TStringConvert.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* TStringConvert.h Copyright (c) Ladislav Zezula 2024 */ 3 | /*---------------------------------------------------------------------------*/ 4 | /* Easy-to-use string conversions Wide <-> Ansi and Wide <-> UTF8 */ 5 | /*---------------------------------------------------------------------------*/ 6 | /* Date Ver Who Comment */ 7 | /* -------- ---- --- ------- */ 8 | /* 04.10.24 1.00 Lad Created */ 9 | /*****************************************************************************/ 10 | 11 | //----------------------------------------------------------------------------- 12 | // Class template for conversions UNICODE <--> UTF-8 13 | 14 | template 15 | class TConvertString 16 | { 17 | public: 18 | 19 | TConvertString() 20 | { 21 | m_szStr = NULL; 22 | m_nLen = 0; 23 | } 24 | 25 | TConvertString(const SRCCHAR * szSrcStr, const SRCCHAR * szSrcEnd = NULL) 26 | { 27 | // Initially, set to NULL string 28 | m_szStr = NULL; 29 | m_nLen = 0; 30 | 31 | // Set the string 32 | SetString(szSrcStr, szSrcEnd); 33 | } 34 | 35 | ~TConvertString() 36 | { 37 | if(m_szStr != NULL && m_szStr != m_StaticBuffer) 38 | delete [] m_szStr; 39 | m_szStr = NULL; 40 | m_nLen = 0; 41 | } 42 | 43 | TRGCHAR * SetString(const SRCCHAR * szSrcStr, const SRCCHAR * szSrcEnd = NULL) 44 | { 45 | if(szSrcStr != NULL) 46 | { 47 | // Set to the pointer to the internal buffer 48 | m_szStr = m_StaticBuffer; 49 | m_StaticBuffer[0] = 0; 50 | 51 | // Retrieve the length of the UTF-8 string 52 | if((m_nLen = ConvertString(NULL, 0, szSrcStr, szSrcEnd)) != 0) 53 | { 54 | // Allocate buffer if too long 55 | if((m_nLen + 1) > _countof(m_StaticBuffer)) 56 | { 57 | if((m_szStr = new TRGCHAR[m_nLen + 1]) == NULL) 58 | { 59 | assert(false); 60 | return NULL; 61 | } 62 | } 63 | 64 | // Convert the string 65 | ConvertString(m_szStr, m_nLen + 1, szSrcStr, szSrcEnd); 66 | } 67 | } 68 | return m_szStr; 69 | } 70 | 71 | size_t ConvertString(LPSTR szTrgStr, size_t ccTrgStr, LPCWSTR szSrcStr, LPCWSTR szSrcEnd) 72 | { 73 | size_t ccSrcStr = (szSrcEnd > szSrcStr) ? (szSrcEnd - szSrcStr) : INVALID_SIZE_T; 74 | size_t nResult; 75 | 76 | // Perform the conversion 77 | nResult = WideCharToMultiByte(CodePage, 0, szSrcStr, (int)(ccSrcStr), szTrgStr, (int)(ccTrgStr), NULL, NULL); 78 | 79 | // Terminate with zero, if needed 80 | if(szSrcEnd && szSrcEnd[0] && szTrgStr) 81 | szTrgStr[nResult] = 0; 82 | return nResult; 83 | } 84 | 85 | size_t ConvertString(LPWSTR szTrgStr, size_t ccTrgStr, LPCSTR szSrcStr, LPCSTR szSrcEnd) 86 | { 87 | // Make sure that we know the length of the target 88 | size_t ccSrcStr = (szSrcEnd > szSrcStr) ? (szSrcEnd - szSrcStr) : INVALID_SIZE_T; 89 | 90 | int nResult = MultiByteToWideChar(CodePage, 0, szSrcStr, (int)ccSrcStr, szTrgStr, (int)(ccTrgStr)); 91 | 92 | if(szTrgStr != NULL) 93 | szTrgStr[nResult] = 0; 94 | return nResult; 95 | } 96 | 97 | TRGCHAR * Buffer() 98 | { 99 | return m_szStr; 100 | } 101 | 102 | size_t Length() 103 | { 104 | return m_nLen; 105 | } 106 | 107 | operator const TRGCHAR *() 108 | { 109 | return m_szStr; 110 | } 111 | 112 | protected: 113 | 114 | bool ConversionFailed(int nResult) 115 | { 116 | return (nResult == 0) && (GetLastError() == ERROR_NO_UNICODE_TRANSLATION); 117 | } 118 | 119 | TRGCHAR * m_szStr; 120 | size_t m_nLen; 121 | TRGCHAR m_StaticBuffer[0x80]; 122 | }; 123 | 124 | //----------------------------------------------------------------------------- 125 | // Classes for conversions Ansi <-> UTF16 and UTF8 <-> UTF16 126 | 127 | typedef TConvertString TAnsiToWide; 128 | typedef TConvertString TUTF8ToWide; 129 | typedef TConvertString TWideToAnsi; 130 | typedef TConvertString TWideToUTF8; 131 | -------------------------------------------------------------------------------- /inc/afxres.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* afxres_mini.h Copyright (c) Ladislav Zezula 2025 */ 3 | /*---------------------------------------------------------------------------*/ 4 | /* This header supplies the most common symbols from afxres..h, */ 5 | /* which allows our VS2022 projects to be build without MFC installed */ 6 | /*---------------------------------------------------------------------------*/ 7 | /* Date Ver Who Comment */ 8 | /* -------- ---- --- ------- */ 9 | /* 07.06.04 1.00 Lad The first version of TToolTip.h */ 10 | /*****************************************************************************/ 11 | 12 | #ifndef __AFXRES_MINI_H__ 13 | #define __AFXRES_MINI_H__ 14 | #ifndef __AFXRES_H__ // Back off if afxres.h has already been included 15 | 16 | #ifndef _INC_WINDOWS 17 | #include "winres.h" // Definitions such as LANG_NEUTRAL 18 | #endif 19 | 20 | //----------------------------------------------------------------------------- 21 | // File commands 22 | 23 | #ifndef ID_FILE_NEW 24 | #define ID_FILE_NEW 0xE100 25 | #endif 26 | 27 | #ifndef ID_FILE_OPEN 28 | #define ID_FILE_OPEN 0xE101 29 | #endif 30 | 31 | #ifndef ID_FILE_CLOSE 32 | #define ID_FILE_CLOSE 0xE102 33 | #endif 34 | 35 | #ifndef ID_FILE_SAVE 36 | #define ID_FILE_SAVE 0xE103 37 | #endif 38 | 39 | #ifndef ID_FILE_SAVE_AS 40 | #define ID_FILE_SAVE_AS 0xE104 41 | #endif 42 | 43 | #ifndef ID_FILE_PRINT 44 | #define ID_FILE_PRINT 0xE107 45 | #endif 46 | 47 | //----------------------------------------------------------------------------- 48 | // View commands (same number used as IDW used for control bar) 49 | // E810 -> E81F must be kept in order for RANGE macros 50 | 51 | #ifndef ID_VIEW_TOOLBAR 52 | #define ID_VIEW_TOOLBAR 0xE800 53 | #endif 54 | 55 | #ifndef ID_VIEW_STATUS_BAR 56 | #define ID_VIEW_STATUS_BAR 0xE801 57 | #endif 58 | 59 | #ifndef ID_VIEW_REBAR 60 | #define ID_VIEW_REBAR 0xE804 61 | #endif 62 | 63 | #ifndef ID_VIEW_AUTOARRANGE 64 | #define ID_VIEW_AUTOARRANGE 0xE805 65 | #endif 66 | 67 | #ifndef ID_VIEW_SMALLICON 68 | #define ID_VIEW_SMALLICON 0xE810 69 | #endif 70 | 71 | #ifndef ID_VIEW_LARGEICON 72 | #define ID_VIEW_LARGEICON 0xE811 73 | #endif 74 | 75 | #ifndef ID_VIEW_LIST 76 | #define ID_VIEW_LIST 0xE812 77 | #endif 78 | 79 | #ifndef ID_VIEW_DETAILS 80 | #define ID_VIEW_DETAILS 0xE813 81 | #endif 82 | 83 | #ifndef ID_VIEW_LINEUP 84 | #define ID_VIEW_LINEUP 0xE814 85 | #endif 86 | 87 | #ifndef ID_VIEW_BYNAME 88 | #define ID_VIEW_BYNAME 0xE815 89 | #endif 90 | 91 | //----------------------------------------------------------------------------- 92 | // Edit commands 93 | 94 | #ifndef ID_EDIT_CLEAR 95 | #define ID_EDIT_CLEAR 0xE120 96 | #endif 97 | 98 | #ifndef ID_EDIT_CLEAR_ALL 99 | #define ID_EDIT_CLEAR_ALL 0xE121 100 | #endif 101 | 102 | #ifndef ID_EDIT_COPY 103 | #define ID_EDIT_COPY 0xE122 104 | #endif 105 | 106 | #ifndef ID_EDIT_CUT 107 | #define ID_EDIT_CUT 0xE123 108 | #endif 109 | 110 | #ifndef ID_EDIT_FIND 111 | #define ID_EDIT_FIND 0xE124 112 | #endif 113 | 114 | #ifndef ID_EDIT_PASTE 115 | #define ID_EDIT_PASTE 0xE125 116 | #endif 117 | 118 | #ifndef ID_EDIT_REPEAT 119 | #define ID_EDIT_REPEAT 0xE128 120 | #endif 121 | 122 | #ifndef ID_EDIT_REPLACE 123 | #define ID_EDIT_REPLACE 0xE129 124 | #endif 125 | 126 | #ifndef ID_EDIT_SELECT_ALL 127 | #define ID_EDIT_SELECT_ALL 0xE12A 128 | #endif 129 | 130 | #ifndef ID_EDIT_UNDO 131 | #define ID_EDIT_UNDO 0xE12B 132 | #endif 133 | 134 | #ifndef ID_EDIT_REDO 135 | #define ID_EDIT_REDO 0xE12C 136 | #endif 137 | 138 | //----------------------------------------------------------------------------- 139 | // Window commands 140 | 141 | #ifndef ID_WINDOW_NEW 142 | #define ID_WINDOW_NEW 0xE130 143 | #endif 144 | 145 | #ifndef ID_WINDOW_ARRANGE 146 | #define ID_WINDOW_ARRANGE 0xE131 147 | #endif 148 | 149 | #ifndef ID_WINDOW_CASCADE 150 | #define ID_WINDOW_CASCADE 0xE132 151 | #endif 152 | 153 | #ifndef ID_WINDOW_TILE_HORZ 154 | #define ID_WINDOW_TILE_HORZ 0xE133 155 | #endif 156 | 157 | #ifndef ID_WINDOW_TILE_VERT 158 | #define ID_WINDOW_TILE_VERT 0xE134 159 | #endif 160 | 161 | #ifndef ID_WINDOW_SPLIT 162 | #define ID_WINDOW_SPLIT 0xE135 163 | #endif 164 | 165 | //----------------------------------------------------------------------------- 166 | // Application commands 167 | 168 | #ifndef ID_APP_ABOUT 169 | #define ID_APP_ABOUT 0xE140 170 | #endif 171 | 172 | #ifndef ID_APP_EXIT 173 | #define ID_APP_EXIT 0xE141 174 | #endif 175 | 176 | //----------------------------------------------------------------------------- 177 | // Property Sheet control id's (determined with Spy++) 178 | 179 | #ifndef ID_APPLY_NOW 180 | #define ID_APPLY_NOW 0x3021 181 | #endif 182 | 183 | #ifndef ID_WIZBACK 184 | #define ID_WIZBACK 0x3023 185 | #endif 186 | 187 | #ifndef ID_WIZNEXT 188 | #define ID_WIZNEXT 0x3024 189 | #endif 190 | 191 | #ifndef ID_WIZFINISH 192 | #define ID_WIZFINISH 0x3025 193 | #endif 194 | 195 | #ifndef AFX_IDC_TAB_CONTROL 196 | #define AFX_IDC_TAB_CONTROL 0x3020 197 | #endif 198 | 199 | #endif // __AFXRES_H__ 200 | #endif // __AFXRES_MINI_H__ 201 | -------------------------------------------------------------------------------- /inc/TIniFile.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* TIniFile.h Copyright (c) Ladislav Zezula 2007-2022 */ 3 | /*---------------------------------------------------------------------------*/ 4 | /* Description: */ 5 | /*---------------------------------------------------------------------------*/ 6 | /* Date Ver Who Comment */ 7 | /* -------- ---- --- ------- */ 8 | /* 05.04.07 1.00 Lad Created */ 9 | /* 24.10.22 1.00 Lad Added support for section-less config files (.vmx) */ 10 | /*****************************************************************************/ 11 | 12 | #ifndef __TINIFILE_H__ 13 | #define __TINIFILE_H__ 14 | 15 | //----------------------------------------------------------------------------- 16 | // Defines 17 | 18 | #define TPI_NONE 0 19 | #define TPI_BOOL 1 20 | #define TPI_INT 2 21 | #define TPI_STRING 3 22 | #define TPI_PASSWORD 4 23 | #define TPI_BINARY 5 24 | #define TPI_MULTISZ 6 25 | 26 | #define INI_FLAG_QUOTED_VALUES 0x00000001 // Variable values are quoted (see a .VMX file) 27 | 28 | //----------------------------------------------------------------------------- 29 | // Structures and classes 30 | 31 | enum TIniEncoding 32 | { 33 | EncodingAnsi = 0, 34 | EncodingUTF16, 35 | EncodingUTF16_BE, 36 | EncodingUTF8, 37 | EncodingMax 38 | }; 39 | 40 | struct TIniVariable 41 | { 42 | LIST_ENTRY Entry; // Link to other variables 43 | LPTSTR szVariableName; 44 | LPTSTR szValue; 45 | size_t nLength; // Length of the allocated buffer in szValue, in TCHARs 46 | }; 47 | 48 | struct TIniSection 49 | { 50 | LIST_ENTRY Entry; // Link to other sections 51 | LIST_ENTRY VarLinks; // Variables within this section 52 | LPTSTR szSectionName; 53 | }; 54 | 55 | class TIniFile 56 | { 57 | public: 58 | 59 | TIniFile(LPCTSTR szIniFileName = NULL); 60 | ~TIniFile(); 61 | 62 | DWORD Load(LPBYTE pbData, size_t cbData, DWORD dwFlags = 0); 63 | DWORD Load(DWORD dwFlags = 0); 64 | DWORD Save(); 65 | 66 | // The "GET" interface 67 | // Strings and multistrings are returned as buffer allocated by "new", the caller must free them 68 | int GetIntValue (LPCTSTR szSection, LPCTSTR szVarName, int nDefValue = 0) const; 69 | BOOL GetBoolValue (LPCTSTR szSection, LPCTSTR szVarName, BOOL bDefValue = FALSE) const; 70 | LPCTSTR GetStringValue (LPCTSTR szSection, LPCTSTR szVarName, LPCTSTR szDefValue = NULL) const; 71 | LPTSTR GetMultiSZValue(LPCTSTR szSection, LPCTSTR szVarName, LPCTSTR szDefValue = NULL) const; 72 | 73 | // The "SET" interface 74 | // Strings and multistrings are returned as buffer allocated by "new", the caller must free them 75 | void SetBoolValue (LPCTSTR szSection, LPCTSTR szVarName, BOOL bValue); 76 | void SetIntValue (LPCTSTR szSection, LPCTSTR szVarName, int nValue); 77 | void SetStringValue (LPCTSTR szSection, LPCTSTR szVarName, LPCTSTR szValue); 78 | void SetMultiSZValue(LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue); 79 | 80 | // The "READ" interface 81 | void ReadBoolValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue, LPCVOID pDefValue) const; 82 | void ReadIntValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue, LPCVOID pDefValue) const; 83 | void ReadStringValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue, LPCVOID pDefValue, size_t nMaxSize) const; 84 | void ReadBinaryValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue, LPCVOID pDefValue, size_t nSize) const; 85 | 86 | // The "WRITE" interface 87 | void WriteBoolValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue); 88 | void WriteIntValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue); 89 | void WriteStringValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue); 90 | void WriteMultiSZValue(LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue); 91 | void WriteBinaryValue (LPCTSTR szSection, LPCTSTR szVarName, LPVOID pValue, size_t nSize); 92 | 93 | // Removing sections and variables 94 | bool RemoveVariable(LPCTSTR szSection, LPCTSTR szVarName); 95 | bool RemoveSection(LPCTSTR szSection); 96 | 97 | // Enumerating sections. NOT THREAD SAFE !!! 98 | TIniSection * FindSectionByName(LPCTSTR szSection) const; 99 | bool GetNextVariable(TIniSection * pSection, TIniVariable ** ppVar); 100 | bool GetNextSection(TIniSection ** ppSection); 101 | 102 | // Get the name of the INI file 103 | LPCTSTR GetFileName(); 104 | 105 | protected: 106 | 107 | TIniSection * InsertNewSection(LPCTSTR szName); 108 | TIniVariable * FindVariableByName(TIniSection * pSection, LPCTSTR szVarName) const; 109 | TIniVariable * InsertNewVariable(TIniSection * pSection, LPCTSTR szName); 110 | void SetVariableValue(TIniVariable * pVar, LPCTSTR szValue); 111 | 112 | int ParseIniFile(LPTSTR szFile, LPTSTR szFileEnd, DWORD dwFlags); 113 | 114 | LPTSTR GetDefaultIniFileName(LPCTSTR szPlainName); 115 | LPTSTR FindEndOfWord(LPTSTR szFile, LPTSTR szFileEnd, TCHAR chExtraChar, LPTSTR * pszDataAfter); 116 | LPTSTR FindEndOfLine(LPTSTR szFile, LPTSTR szFileEnd, LPTSTR * pszDataAfter); 117 | LPTSTR TrimVariableValue(LPTSTR szString, DWORD dwFlags); 118 | // DWORD CalcNameHash(LPCTSTR szName); 119 | 120 | bool StringToBool(LPCTSTR szStr, PBOOL pbBool) const; 121 | bool StringToInt(LPCTSTR szStr, int * piInt) const; 122 | void SwapBuffer_UINT16(LPBYTE pbTrgBuffer, LPBYTE pbSrcBuffer, size_t cbBuffer); 123 | bool IsFullPathName(LPCTSTR szPath); 124 | LPTSTR NewName(LPCTSTR szString); 125 | 126 | LIST_ENTRY m_SectionLinks; 127 | LPTSTR m_szIniFileName; 128 | TIniEncoding m_Encoding; 129 | }; 130 | 131 | #endif -------------------------------------------------------------------------------- /inc/TDropHelper.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* TDropHelper.h Copyright (c) Ladislav Zezula 2008 */ 3 | /*---------------------------------------------------------------------------*/ 4 | /* Helper classes for implementing drag&drop operations */ 5 | /* */ 6 | /* To use the drag&drop support for a window (e.g. list view): */ 7 | /* */ 8 | /* Drop support: */ 9 | /* - After creation of the window, create a new instance of TDropHelper */ 10 | /* - Query for the IID_IDropTarget and use it as parameter */ 11 | /* for RegisterDragDrop call. */ 12 | /* - Don't forget to release the IDropTarget when the window is destroyed */ 13 | /* */ 14 | /* Drag support: */ 15 | /* - When drag operation is being initiated (e.g. at LVN_BEGINDRAG notify), */ 16 | /* create new instance of TDataObject. */ 17 | /* - Set the drag source window (TDropHelper::SetDragSourceWindow) */ 18 | /* - Set the data rendering procedure by (TDataObject::SetRenderDataProc) */ 19 | /* - Query the TDropHelper for IDropSource */ 20 | /* - Query the TDataObject for IDataObject */ 21 | /* - Use both interfaces as arguments for DoDragDrop */ 22 | /* - Reset the drag source window (TDropHelper::SetDragSourceWindow) */ 23 | /* - Release IDataObject IDropSource */ 24 | /* */ 25 | /*---------------------------------------------------------------------------*/ 26 | /* Date Ver Who Comment */ 27 | /* -------- ---- --- ------- */ 28 | /* 02.04.08 1.00 Lad The first version of TDropHelper.h */ 29 | /*****************************************************************************/ 30 | 31 | #ifndef __TDROPHELPER_H__ 32 | #define __TDROPHELPER_H__ 33 | 34 | typedef HDROP (*RENDER_SOURCE_DATA_PROC)(HWND hWnd); 35 | 36 | // Represents the data object for the source of the OLE drag&drop operation 37 | class TDataObject : public IEnumFORMATETC, public IMarshal, public IDataObject 38 | { 39 | public: 40 | 41 | TDataObject(); 42 | 43 | // Public functions 44 | void SetRenderDataProc(RENDER_SOURCE_DATA_PROC pfnRenderDataProc, HWND hWnd); 45 | 46 | // Functions of IUnknown interface 47 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject); 48 | ULONG STDMETHODCALLTYPE AddRef(); 49 | ULONG STDMETHODCALLTYPE Release(); 50 | 51 | // Functions of the IEnumFORMATETC 52 | HRESULT STDMETHODCALLTYPE Next(ULONG celt, FORMATETC * rgelt, ULONG * pceltFetched); 53 | HRESULT STDMETHODCALLTYPE Skip(ULONG celt); 54 | HRESULT STDMETHODCALLTYPE Reset(void); 55 | HRESULT STDMETHODCALLTYPE Clone(IEnumFORMATETC ** ppenum); 56 | 57 | // Functions of the IMarshal 58 | HRESULT STDMETHODCALLTYPE GetUnmarshalClass(REFIID riid, void * pv, DWORD dwDestContext, void * pvDestContext, DWORD mshlflags, CLSID * pCid); 59 | HRESULT STDMETHODCALLTYPE GetMarshalSizeMax(REFIID riid, void * pv, DWORD dwDestContext, void * pvDestContext, DWORD mshlflags, ULONG * pSize); 60 | HRESULT STDMETHODCALLTYPE MarshalInterface( 61 | IStream * pStm, 62 | REFIID riid, 63 | void * pv, 64 | DWORD dwDestContext, 65 | void * pvDestContext, 66 | DWORD mshlflags 67 | ); 68 | 69 | 70 | 71 | // Functions of the IDataObject 72 | HRESULT STDMETHODCALLTYPE GetData(FORMATETC * pFormatetc, STGMEDIUM * pmedium); 73 | HRESULT STDMETHODCALLTYPE GetDataHere(FORMATETC * pFormatetc, STGMEDIUM * pmedium); 74 | HRESULT STDMETHODCALLTYPE QueryGetData(FORMATETC * pFormatetc); 75 | HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut); 76 | HRESULT STDMETHODCALLTYPE SetData(FORMATETC * pFormatetc, STGMEDIUM * pmedium, BOOL fRelease); 77 | HRESULT STDMETHODCALLTYPE EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC ** ppenumFormatetc); 78 | HRESULT STDMETHODCALLTYPE DAdvise(FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection); 79 | HRESULT STDMETHODCALLTYPE DUnadvise(DWORD dwConnection); 80 | HRESULT STDMETHODCALLTYPE EnumDAdvise(IEnumSTATDATA ** ppenumAdvise); 81 | 82 | protected: 83 | 84 | ~TDataObject(); 85 | 86 | RENDER_SOURCE_DATA_PROC m_pfnRenderDataProc; 87 | HWND m_hWnd; 88 | ULONG m_dwFormatPos; 89 | ULONG m_dwRefs; 90 | }; 91 | 92 | 93 | class TDropHelper : public IDropSource, public IDropTarget 94 | { 95 | public: 96 | 97 | TDropHelper(); 98 | 99 | // Functions of IUnknown interface 100 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject); 101 | ULONG STDMETHODCALLTYPE AddRef(); 102 | ULONG STDMETHODCALLTYPE Release(); 103 | 104 | // Functions of the IDropSource 105 | HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState); 106 | HRESULT STDMETHODCALLTYPE GiveFeedback(DWORD dwEffect); 107 | 108 | // Functions of the IDropTarget 109 | HRESULT STDMETHODCALLTYPE DragEnter(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect); 110 | HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD * pdwEffect); 111 | HRESULT STDMETHODCALLTYPE DragLeave(void); 112 | HRESULT STDMETHODCALLTYPE Drop(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect); 113 | 114 | protected: 115 | 116 | ~TDropHelper(); 117 | 118 | IDataObject * m_pDataObject; 119 | HWND m_hWnd; 120 | ULONG m_dwRefs; 121 | }; 122 | 123 | #endif // __TDROPHELPER_H__ 124 | -------------------------------------------------------------------------------- /inc/TAnchors.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* TAnchors.h Copyright Ladislav Zezula 2001 */ 3 | /*---------------------------------------------------------------------------*/ 4 | /* A class for easy object anchoring. Those who compare the Delphi program- */ 5 | /* ming with Visual C++, will certainly miss the "Anchors" property in visual*/ 6 | /* design. This class supports something like that, although it's not so */ 7 | /* comfort like the visual design in Delphi/C++ builder */ 8 | /*---------------------------------------------------------------------------*/ 9 | /* Date Ver Who Comment */ 10 | /* -------- ---- --- -----------------------------------------------------*/ 11 | /* 19.12.01 1.00 Lad Created */ 12 | /* 31.08.04 2.00 Lad Added support for proportional resizing */ 13 | /*****************************************************************************/ 14 | 15 | #ifndef __TANCHORS_H__ 16 | #define __TANCHORS_H__ 17 | 18 | //----------------------------------------------------------------------------- 19 | // Constants 20 | 21 | // Anchor types 22 | #define akTop 0x00000001 // Bind the window's upper edge to the parent's top border 23 | #define akTopCenter 0x00000002 // Bind the window's upper edge to the parent's center 24 | #define akLeft 0x00000010 // Bind the window's left edge to the parent's left border 25 | #define akLeftCenter 0x00000020 // Bind the window's left edge to the parent's center 26 | #define akRight 0x00000100 // Bind the window's right edge to the parent's right border 27 | #define akRightCenter 0x00000200 // Bind the window's right edge to the parent's center 28 | #define akBottom 0x00001000 // Bind the window's bottom edge to the parent's bottom border 29 | #define akBottomCenter 0x00002000 // Bind the window's bottom edge to the parent's center 30 | 31 | #define akNotAnchored (int)0x80000000 // This edge is not anchored 32 | 33 | #define akLeftTop (akLeft | akTop) 34 | #define akRightBottom (akRight | akBottom) 35 | #define akAll (akLeft | akTop | akRight | akBottom) 36 | 37 | typedef BOOL (*CALCCHILDPOS)(HWND hWndChild, PVOID pvUserParam, const RECT & NewClientRect, WINDOWPOS & NewChildPos); 38 | 39 | typedef enum _WNDCLS 40 | { 41 | WndNotSpecified, 42 | WndDialogBox, // The control is a dialog box 43 | WndTabControl, // The control is a tab control 44 | WndComboDropDown, // The control is a combo box with editable window (CBS_DROPDOWN) 45 | } WNDCLS, *PWNDCLS; 46 | 47 | struct TAnchorPT 48 | { 49 | TAnchorPT(int nRelPt, int nDelta); // Bind the window to a specified point in the parent's client area 50 | TAnchorPT(); 51 | 52 | // Recalculates the relative point to absolute point 53 | int AbsPoint(const SIZE & sizeParent, DWORD dwEdge); 54 | 55 | bool IsAnchored() 56 | { 57 | return (RelPt != akNotAnchored); 58 | } 59 | 60 | int RelPt; // The anchor is related to the percent size of the parent's CX/CY 61 | // Example : 0 is left-most or top-most point in the parent's client area 62 | // 50 is is center of the parent's client CX/CY 63 | // 100 is right-most or bottom-most point of the parent's client area 64 | // The value of RelPt = akNotAnchored means that this edge is not anchored 65 | 66 | int Delta; // Fixed distance from the relative point. This only changes when the DPI changes 67 | // The client position of the window is at RelativePoint + Delta 68 | }; 69 | 70 | class TAnchor 71 | { 72 | public: 73 | 74 | TAnchor(HWND hWndChild); 75 | ~TAnchor(); 76 | 77 | // Initializing the anchor either from anchors or from custom callback 78 | void Initialize(HWND hWndParent, int aptLeft, int aptTop, int aptRight, int aptBottom); 79 | void Initialize(HWND hWndParent, CALCCHILDPOS PfnCalcChildPos, PVOID pvUserParam); 80 | 81 | // Recalculate for a new DPI 82 | void NewDpi(const RECT & rectParent); 83 | 84 | protected: 85 | 86 | // Calculates the control's rectangle, relative to parent's client area 87 | void UpdateControlRect(HWND hWndParent, LPRECT pRectParent, LPRECT pRectControl); 88 | 89 | public: 90 | 91 | LIST_ENTRY Entry; // Links to other anchors 92 | 93 | #ifdef _DEBUG 94 | TCHAR szClassName[80]; // Class name of the control 95 | TCHAR szWindowText[80]; // Text of the control (possibly truncated 96 | #endif 97 | 98 | HWND hWnd; // Handle to the child (anchored) window 99 | RECT rect; // Rectangle of the control (relative to parent's client area) 100 | 101 | CALCCHILDPOS PfnCalcChildPos; // Custom callback for calculating the child window position 102 | LPARAM SaveSelection; // Used for dropdown combo boxes during resize 103 | PVOID pvUserParam; // User parameter for PfnCalcChildPos 104 | 105 | public: 106 | 107 | TAnchorPT Top; // Anchor of the top edge of the window 108 | TAnchorPT Left; // Anchor of the left edge of the window 109 | TAnchorPT Right; // Anchor of the right edge of the window 110 | TAnchorPT Bottom; // Anchor of the bottom edge of the window 111 | WNDCLS WndType; // Special window type 112 | }; 113 | 114 | class TAnchors 115 | { 116 | public: 117 | 118 | TAnchors(HWND hWndParent); 119 | ~TAnchors(); 120 | 121 | // Adding anchors 122 | TAnchor * AddAnchor(HWND hWndChild, DWORD dwAnchors); 123 | TAnchor * AddAnchor(HWND hDlg, UINT nIDCtrl, DWORD dwAnchors); 124 | 125 | TAnchor * AddAnchor(HWND hWndChild, CALCCHILDPOS PfnGetNewChildRect, PVOID pvUserParam); 126 | TAnchor * AddAnchor(HWND hDlg, UINT nIDCtrl, CALCCHILDPOS PfnGetNewChildRect, PVOID pvUserParam); 127 | 128 | TAnchor * AddAnchor(HWND hWndChild, int aptLeft, int aptTop, int aptRight, int aptBottom); 129 | TAnchor * AddAnchor(HWND hDlg, UINT nIDCtrl, int aptLeft, int aptTop, int aptRight, int aptBottom); 130 | 131 | // Removes the anchor from the list. Note that this does NOT destroy the window. 132 | bool RemoveAnchor(TAnchor * pAnchor); 133 | 134 | // Returns the parent window 135 | HWND GetParentWindow() 136 | { 137 | return m_hWndParent; 138 | } 139 | 140 | // Call this method in the handler of WM_SIZE (or OnSize in MFC) 141 | BOOL OnSize(); 142 | BOOL OnGetMinMaxInfo(LPARAM lParam); 143 | BOOL OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 144 | 145 | protected: 146 | 147 | TAnchor * CreateNewAnchor(HWND hWndChild); 148 | void InsertAnchor(TAnchor * pAnchor); 149 | SIZE & SavePreviousSize(); 150 | 151 | // Calculates new window position and size 152 | BOOL GetNewChildRect(TAnchor * pAnchor, const RECT & NewClientRect, WINDOWPOS & NewChildPos); 153 | void ComboBox_SaveSelection(TAnchor * pAnchor); 154 | bool IsDialogAfterDpiChange(bool bUpdateDPI = false); 155 | void RescaleForDpi(); 156 | 157 | LIST_ENTRY m_AnchorLinks; 158 | SIZE m_sizeLast; // Previously saved window rectangle of the dialog 159 | SIZE m_sizeMin; // Minimal size of the dialog 160 | HWND m_hWndParent; // Parent window of the anchored controls 161 | UINT m_bThemeActive:1; // TRUE if the XP+ theme is active 162 | UINT m_bIsDialog:1; // TRUE if the marend window is a dialog box 163 | UINT m_nAnchors; // Number of anchors 164 | UINT m_nDPI; // Previously saved DPI 165 | }; 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /inc/Utils.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* Utils.h Copyright (c) Ladislav Zezula 2004 */ 3 | /*---------------------------------------------------------------------------*/ 4 | /* Main header file for the Utils library. Include in your project to have */ 5 | /* access to all utility functions */ 6 | /* */ 7 | /* MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) */ 8 | /* MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) */ 9 | /* MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) */ 10 | /* MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) */ 11 | /* MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) */ 12 | /* MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005, WDK build) */ 13 | /* MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio 2003) */ 14 | /* MSVC++ 7.0 _MSC_VER == 1300 */ 15 | /* MSVC++ 6.0 _MSC_VER == 1200 */ 16 | /* MSVC++ 5.0 _MSC_VER == 1100 */ 17 | /* */ 18 | /*---------------------------------------------------------------------------*/ 19 | /* Date Ver Who Comment */ 20 | /* -------- ---- --- ------- */ 21 | /* 29.05.04 1.00 Lad The first version of Utils.h */ 22 | /*****************************************************************************/ 23 | 24 | #ifndef __UTILS_H__ 25 | #define __UTILS_H__ 26 | 27 | #ifndef _WIN32_WINNT 28 | #define _WIN32_WINNT 0x0500 // _WIN32_WINNT is not defined in VS 2005 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #if(_MSC_VER >= 1500) // Supported in Visual Studio 2008+ 43 | #pragma warning(disable: 4995) // intrin.h(374) : warning C4995: 'strcat': name was marked as #pragma deprecated 44 | #include 45 | #endif 46 | 47 | #pragma warning(disable: 28193) // PreFAST: 'dwErrCode' holds a value that must be examined. 48 | #pragma warning(disable: 28197) // PreFAST: Possibly leaking memory 'pNewAnchor' 49 | 50 | //----------------------------------------------------------------------------- 51 | // Use the appropriate library 52 | // 53 | // The library type is encoded in the library name as the following UtilsXYZ.lib: 54 | // 55 | // X - D for Debug version, R for Release version 56 | // Y - A for ANSI version, U for Unicode version 57 | // Z - S for static-linked CRT library, D for multithreaded DLL CRT library 58 | // 59 | 60 | #if defined(_MSC_VER) && !defined(__UTILS_SELF__) 61 | #ifndef WDK_BUILD 62 | #ifdef _DEBUG // DEBUG VERSIONS 63 | #ifndef _UNICODE 64 | #ifdef _DLL 65 | #pragma comment(lib, "UtilsDAD.lib") // Debug Ansi CRT-DLL version 66 | #else 67 | #pragma comment(lib, "UtilsDAS.lib") // Debug Ansi CRT-LIB version 68 | #endif 69 | #else 70 | #ifdef _DLL 71 | #pragma comment(lib, "UtilsDUD.lib") // Debug Unicode CRT-DLL version 72 | #else 73 | #pragma comment(lib, "UtilsDUS.lib") // Debug Unicode CRT-LIB version 74 | #endif 75 | #endif 76 | #else // RELEASE VERSIONS 77 | #ifndef _UNICODE 78 | #ifdef _DLL 79 | #pragma comment(lib, "UtilsRAD.lib") // Release Ansi CRT-DLL version 80 | #else 81 | #pragma comment(lib, "UtilsRAS.lib") // Release Ansi CRT-LIB version 82 | #endif 83 | #else 84 | #ifdef _DLL 85 | #pragma comment(lib, "UtilsRUD.lib") // Release Unicode CRT-DLL version 86 | #else 87 | #pragma comment(lib, "UtilsRUS.lib") // Release Unicode CRT-LIB version 88 | #endif 89 | #endif 90 | #endif 91 | #else 92 | #pragma comment(lib, "UtilsWDK.lib") // MSVCRT.DLL-based library made by WDK build 93 | #endif 94 | #endif 95 | 96 | //----------------------------------------------------------------------------- 97 | // Manifest 98 | // 99 | // Set the linker and manifest options to the following: 100 | // - Linker\Manifest File\Generate manifest: Yes 101 | // - Linker\Manifest File\Additional Manifest Dependencies: 102 | // - Linker\Manifest File\Allow Isolation: Yes 103 | // - Manifest Tool\Input and Output\Additional manifest files: 104 | // - Manifest Tool\Input and Output\Input Resource Manifests: 105 | // - Manifest Tool\Input and Output\Embed Manifest: Yes 106 | // 107 | 108 | #ifndef _NO_UTILS_MANIFEST 109 | #if _MSC_VER >= 1400 110 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 111 | #endif 112 | #endif // _NO_UTILS_MANIFEST 113 | 114 | //----------------------------------------------------------------------------- 115 | // Resource strings 116 | 117 | #define IDS_ERROR 1 // "Error" 118 | #define IDS_CONFIRM 2 // "Confirmation" 119 | #define IDS_QUESTION 3 // "Question" 120 | #define IDS_INFO 4 // "Information" 121 | #define IDS_WARNING 5 // "Warning" 122 | #define IDS_REQUEST 6 // "Request" 123 | #define IDS_RETRYCANCEL 7 // Dummy string for "Retry/Cancel" MessageBox 124 | #define IDS_BTN_OK 8 // "&Ok" 125 | #define IDS_BTN_CANCEL 9 // "&Cancel" 126 | #define IDS_BTN_ABORT 10 // "&Abort" 127 | #define IDS_BTN_RETRY 11 // "&Retry" 128 | #define IDS_BTN_IGNORE 12 // "&Ignore" 129 | #define IDS_BTN_YES 13 // "&Yes" 130 | #define IDS_BTN_NO 14 // "&No" 131 | #define IDS_BTN_CLOSE 15 // "&Close" 132 | #define IDS_BTN_HELP 16 // "&Help" 133 | #define IDS_BTN_TRYAGAIN 17 // "&Try Again" 134 | #define IDS_BTN_CONTINUE 18 // "Continue" 135 | #define IDS_BTN_TIMEOUT 19 // "Timeout" 136 | #define IDS_BTN_YESALL 20 // "Yes All" 137 | #define IDS_BTN_NOALL 21 // "No All" 138 | 139 | //----------------------------------------------------------------------------- 140 | // Special buttons for "Yes/Yes All/No/Cancel" message boxes 141 | 142 | #define IDYESTOALL (IDNO+(IDS_BTN_YESALL-IDS_BTN_NO)) 143 | #define IDNOTOALL (IDNO+(IDS_BTN_NOALL-IDS_BTN_NO)) 144 | 145 | #define LISTVIEW_LAST_ITEM 0x7FFFFFFF // The highest item ID 146 | 147 | //----------------------------------------------------------------------------- 148 | // Defines that are not present in older SDKs 149 | 150 | #ifndef SS_REALSIZECONTROL 151 | #define SS_REALSIZECONTROL 0x00000040L 152 | #endif 153 | 154 | #ifndef HDF_SORTUP 155 | #define HDF_SORTUP 0x0400 156 | #define HDF_SORTDOWN 0x0200 157 | #endif 158 | 159 | #ifndef LVS_EX_DOUBLEBUFFER 160 | #define LVS_EX_DOUBLEBUFFER 0x00010000 161 | #endif 162 | 163 | #ifndef LVIF_COLUMNS 164 | #define LVIF_COLUMNS 0x00000200 165 | #endif 166 | 167 | #ifndef LVM_SETVIEW 168 | #define LV_VIEW_ICON 0x0000 169 | #define LV_VIEW_DETAILS 0x0001 170 | #define LV_VIEW_SMALLICON 0x0002 171 | #define LV_VIEW_LIST 0x0003 172 | #define LV_VIEW_TILE 0x0004 173 | #define LV_VIEW_MAX 0x0004 174 | #define LVM_SETVIEW (LVM_FIRST + 142) 175 | #define LVM_GETVIEW (LVM_FIRST + 143) 176 | #endif // LVM_SETVIEW 177 | 178 | #ifndef TVIF_EXPANDEDIMAGE 179 | #define TVIF_EXPANDEDIMAGE 0x0200 180 | #endif 181 | 182 | #ifndef PBM_SETSTATE 183 | #define PBM_SETSTATE (WM_USER+16) // wParam = PBST_[State] (NORMAL, ERROR, PAUSED) 184 | #define PBST_NORMAL 0x0001 185 | #define PBST_ERROR 0x0002 186 | #define PBST_PAUSED 0x0003 187 | #endif // PBM_SETSTATE 188 | 189 | #ifndef WM_DPICHANGED 190 | #define WM_DPICHANGED 0x02E0 191 | #endif 192 | 193 | #ifndef WM_THEMECHANGED 194 | #define WM_THEMECHANGED 0x031A 195 | #endif 196 | 197 | // Windows older than 2000 don't accept sizeof(MENUITEMINFO) greater than MENUITEMINFO_V4_SIZE 198 | #define MENUITEMINFO_V4_SIZE FIELD_OFFSET(MENUITEMINFO, hbmpItem) 199 | 200 | // TVITEMEX for Windows Vista or newer 201 | typedef struct tagTVITEMEX_V6 202 | { 203 | UINT mask; 204 | HTREEITEM hItem; 205 | UINT state; 206 | UINT stateMask; 207 | LPTSTR pszText; 208 | int cchTextMax; 209 | int iImage; 210 | int iSelectedImage; 211 | int cChildren; 212 | LPARAM lParam; 213 | int iIntegral; 214 | UINT uStateEx; 215 | HWND hwnd; 216 | int iExpandedImage; 217 | int iReserved; 218 | } TVITEMEX_V6, *LPTVITEMEX_V6; 219 | 220 | // TVINSERTSTRUCT for Windows Vista or newer 221 | typedef struct tagTVINSERTSTRUCT_V6 222 | { 223 | HTREEITEM hParent; 224 | HTREEITEM hInsertAfter; 225 | TVITEMEX_V6 item; 226 | 227 | } TVINSERTSTRUCT_V6, *LPTVINSERTSTRUCT_V6; 228 | 229 | //----------------------------------------------------------------------------- 230 | // Macros 231 | 232 | // 233 | // Support for ssize_t type 234 | // 235 | 236 | #ifndef ssize_t 237 | #ifdef _WIN64 238 | typedef signed __int64 ssize_t; 239 | #else 240 | typedef signed int ssize_t; 241 | #endif 242 | #endif 243 | 244 | // 245 | // Macro for an invalid size_t 246 | // 247 | 248 | #ifndef INVALID_SIZE_T 249 | #define INVALID_SIZE_T (size_t)(-1) 250 | #endif 251 | 252 | // 253 | // LPCBYTE not defined in WDK headers 254 | // 255 | 256 | #ifndef LPCBYTE 257 | typedef const BYTE *LPCBYTE; 258 | #endif 259 | 260 | // 261 | // Use with #pragma TODO("This needs to be fixed") 262 | // 263 | 264 | #ifndef TODO 265 | #define chSTR2(x) #x 266 | #define chSTR(x) chSTR2(x) 267 | #define TODO(todo) message(__FILE__ "(" chSTR(__LINE__) ") : TODO: " #todo) 268 | #endif // TODO 269 | 270 | // 271 | // Macro for setting pointer window data, to compensate the improper declaration 272 | // of SetWindowLongPtr on 32-bit targets in the SDK 273 | // SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)ptr) should no longer give any warnings on /W4 274 | // 275 | 276 | #if !defined(WIN64) && !defined(_WIN64) 277 | #undef SetWindowLongPtrA 278 | #undef SetWindowLongPtrW 279 | #define SetWindowLongPtrA(hwnd, nIndex, value) SetWindowLongA(hwnd, nIndex, (LONG)(LONG_PTR)value); 280 | #define SetWindowLongPtrW(hwnd, nIndex, value) SetWindowLongW(hwnd, nIndex, (LONG)(LONG_PTR)value); 281 | #endif 282 | 283 | // 284 | // Macro for self-crash dump creation 285 | // 286 | 287 | #define CRASHDUMP_TRY __try 288 | #define CRASHDUMP_INVOKE() { *(char *)0 = 0; } 289 | #define CRASHDUMP_EXCEPT __except(WriteDumpFile(NULL, GetExceptionInformation())) 290 | 291 | // 292 | // Macro for aligning value to nearest-upper size of 'a' 293 | // 294 | 295 | #ifndef ALIGN_TO_SIZE 296 | #define ALIGN_TO_SIZE(x, a) (((x) + (a)-1) & ~((a)-1)) 297 | #endif 298 | 299 | // 300 | // Macro for page size in Win32 301 | // 302 | 303 | #ifndef WIN32_PAGE_SIZE 304 | #define WIN32_PAGE_SIZE 0x1000 305 | #endif 306 | 307 | // 308 | // Base default DPI value 309 | // 310 | 311 | #ifndef USER_DEFAULT_SCREEN_DPI 312 | #define USER_DEFAULT_SCREEN_DPI 96 313 | #define USER_MAX_SCREEN_DPI 504 314 | #endif 315 | 316 | // 317 | // Defines for Windows version returned by GetWindowsVersion() 318 | // 319 | 320 | #define OSVER_WINDOWS_2000 0x0500 321 | #define OSVER_WINDOWS_XP 0x0501 322 | #define OSVER_WINDOWS_2003 0x0502 323 | #define OSVER_WINDOWS_VISTA 0x0600 324 | #define OSVER_WINDOWS_7 0x0601 325 | #define OSVER_WINDOWS_8 0x0602 326 | #define OSVER_WINDOWS_8_1 0x0603 327 | #define OSVER_WINDOWS_10 0x0A00 328 | #define OSVER_WINDOWS_11 0x0B00 329 | 330 | // 331 | // Defines for Windows build returned by GetWindowsBuildNumber() 332 | // 333 | 334 | #define OSBUILD_WINDOWS_NT 1381 335 | #define OSBUILD_WINDOWS_2000 2195 336 | #define OSBUILD_WINDOWS_XP 2600 337 | #define OSBUILD_WINDOWS_2003 3790 338 | #define OSBUILD_WINDOWS_VISTA 6000 339 | #define OSBUILD_WINDOWS_7 7600 340 | #define OSBUILD_WINDOWS_8 9200 341 | #define OSBUILD_WINDOWS_8_1 9600 342 | #define OSBUILD_WINDOWS_10 10240 343 | #define OSBUILD_WINDOWS_10_TS2 10586 // Windows 10 Threshold 2 344 | #define OSBUILD_WINDOWS_10_RS1 14393 // Windows 10 Redstone 1 (1607) 345 | #define OSBUILD_WINDOWS_10_RS2 15063 // Windows 10 Redstone 2 (1703) 346 | #define OSBUILD_WINDOWS_10_RS3 16299 // Windows 10 Redstone 3 (1709) 347 | #define OSBUILD_WINDOWS_10_RS4 17134 // Windows 10 Redstone 4 (1803) 348 | #define OSBUILD_WINDOWS_10_RS5 17763 // Windows 10 Redstone 4 (1809) 349 | 350 | // 351 | // Support for std::tstring, which works like std::string or std::wstring 352 | // 353 | 354 | #ifdef _STRING_ 355 | #if defined(UNICODE) || defined(_UNICODE) 356 | #define tstring wstring 357 | #else 358 | #define tstring string 359 | #endif 360 | #endif // _STRING 361 | 362 | //----------------------------------------------------------------------------- 363 | // Structures 364 | 365 | struct TListViewColumns 366 | { 367 | UINT nIDTitle; // The title of the list view (string resource ID) 368 | int nWidth; // The width of the list view. -1 means that the item's 369 | // width is up to the listview width 370 | }; 371 | 372 | //----------------------------------------------------------------------------- 373 | // Macros / inline functions 374 | 375 | // 376 | // Macros for 32-bit rotate operations. 377 | // VS 2008+ has support for _lrotl/_lrotr, so the call is inlined into rol/ror 378 | // WDK6001 can still recognize these as rol/ror and uses inline assembly 379 | // 380 | 381 | #if(_MSC_VER >= 1500) 382 | 383 | #pragma intrinsic(_lrotl, _lrotr) 384 | #define RolOperation(dwValue, dwRolCount) _lrotl(dwValue, dwRolCount) 385 | #define RorOperation(dwValue, dwRorCount) _lrotr(dwValue, dwRorCount) 386 | 387 | #else 388 | 389 | ULONG FORCEINLINE RolOperation(ULONG dwValue, ULONG dwRolCount) 390 | { 391 | // Ror by (0x20 + x) is the same like ror by x 392 | dwRolCount &= 0x1F; 393 | return (dwValue << dwRolCount) | (dwValue >> (0x20 - dwRolCount)); 394 | } 395 | 396 | ULONG FORCEINLINE RorOperation(ULONG dwValue, ULONG dwRorCount) 397 | { 398 | // Ror by (0x20 + x) is the same like ror by x 399 | dwRorCount &= 0x1F; 400 | return (dwValue >> dwRorCount) | (dwValue << (0x20 - dwRorCount)); 401 | } 402 | 403 | #endif // (_MSC_VER >= 1500) 404 | 405 | // 406 | // Easy access to a width or height of a rectangle 407 | // 408 | 409 | inline int RectCX(const RECT & rect) 410 | { 411 | return rect.right - rect.left; 412 | } 413 | 414 | inline int RectCY(const RECT & rect) 415 | { 416 | return rect.bottom - rect.top; 417 | } 418 | 419 | // 420 | // Macros for handling LIST_ENTRY-based lists 421 | // 422 | 423 | #if !defined(_WDMDDK_) && !defined(_LIST_ENTRY_MACROS_DEFINED_) 424 | #define _LIST_ENTRY_MACROS_DEFINED_ 425 | 426 | BOOLEAN 427 | FORCEINLINE 428 | IsListEmpty( 429 | IN const LIST_ENTRY * ListHead 430 | ) 431 | { 432 | return (BOOLEAN)(ListHead->Flink == ListHead); 433 | } 434 | 435 | FORCEINLINE 436 | VOID 437 | InitializeListHead( 438 | IN PLIST_ENTRY ListHead 439 | ) 440 | { 441 | ListHead->Flink = ListHead->Blink = ListHead; 442 | } 443 | 444 | FORCEINLINE 445 | VOID 446 | InsertHeadList( 447 | IN PLIST_ENTRY ListHead, 448 | IN PLIST_ENTRY Entry 449 | ) 450 | { 451 | PLIST_ENTRY Flink; 452 | 453 | Flink = ListHead->Flink; 454 | Entry->Flink = Flink; 455 | Entry->Blink = ListHead; 456 | Flink->Blink = Entry; 457 | ListHead->Flink = Entry; 458 | } 459 | 460 | FORCEINLINE 461 | VOID 462 | InsertTailList( 463 | IN PLIST_ENTRY ListHead, 464 | IN PLIST_ENTRY Entry 465 | ) 466 | { 467 | PLIST_ENTRY Blink; 468 | 469 | Blink = ListHead->Blink; 470 | Entry->Flink = ListHead; 471 | Entry->Blink = Blink; 472 | Blink->Flink = Entry; 473 | ListHead->Blink = Entry; 474 | } 475 | 476 | FORCEINLINE 477 | BOOLEAN 478 | RemoveEntryList( 479 | IN PLIST_ENTRY Entry 480 | ) 481 | { 482 | PLIST_ENTRY Blink; 483 | PLIST_ENTRY Flink; 484 | 485 | Flink = Entry->Flink; 486 | Blink = Entry->Blink; 487 | Blink->Flink = Flink; 488 | Flink->Blink = Blink; 489 | return (BOOLEAN)(Flink == Blink); 490 | } 491 | #endif // #if !defined(_WDMDDK_) && !defined(_LIST_ENTRY_MACROS_DEFINED_) 492 | 493 | // 494 | // Useful in FindFirstFile/FindNextFile loops 495 | // 496 | 497 | FORCEINLINE bool IsDotDirectoryName(LPCTSTR szFileName) 498 | { 499 | // Check for the first dot 500 | if(*szFileName++ == _T('.')) 501 | { 502 | // Check for the second dot 503 | if(*szFileName == _T('.')) 504 | szFileName++; 505 | return (szFileName[0] == 0); 506 | } 507 | return false; 508 | } 509 | 510 | //----------------------------------------------------------------------------- 511 | // Global variables 512 | 513 | // Must be defined by the application. It is the instance of the 514 | // module where to load resources from 515 | extern HINSTANCE g_hInst; 516 | extern HANDLE g_hHeap; 517 | 518 | // Common Windows library names 519 | extern const TCHAR * const g_szNtdllDll; 520 | extern const TCHAR * const g_szKernel32Dll; 521 | extern const TCHAR * const g_szAdvapi32Dll; 522 | extern const TCHAR * const g_szUser32Dll; 523 | 524 | // String conversion tables 525 | extern const char * Base64Table_Standard; 526 | extern const char * IntToHexChar; 527 | extern const BYTE CharToByte[0x100]; 528 | 529 | //----------------------------------------------------------------------------- 530 | // Easy conversions between ANSI and UNICODE 531 | 532 | _inline size_t StringCchCopyX(LPSTR szBuffer, size_t ccBuffer, LPCSTR szString) 533 | { 534 | LPSTR szBufferEnd = NULL; 535 | 536 | StringCchCopyExA(szBuffer, ccBuffer, szString, &szBufferEnd, NULL, 0); 537 | return (szBufferEnd - szBuffer); 538 | } 539 | 540 | _inline size_t StringCchCopyX(LPWSTR szBuffer, size_t ccBuffer, LPCWSTR szString) 541 | { 542 | LPWSTR szBufferEnd = NULL; 543 | 544 | StringCchCopyExW(szBuffer, ccBuffer, szString, &szBufferEnd, NULL, 0); 545 | return (szBufferEnd - szBuffer); 546 | } 547 | 548 | _inline size_t StringCchCopyX(LPSTR szBuffer, size_t ccBuffer, LPCWSTR szString) 549 | { 550 | int nLength = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, szString, -1, szBuffer, (int)ccBuffer, NULL, NULL); 551 | return (nLength > 0) ? (nLength - 1) : 0; 552 | } 553 | 554 | _inline size_t StringCchCopyX(LPWSTR szBuffer, size_t ccBuffer, LPCSTR szString) 555 | { 556 | int nLength = MultiByteToWideChar(CP_ACP, 0, szString, -1, szBuffer, (int)ccBuffer); 557 | return (nLength > 0) ? (nLength - 1) : 0; 558 | } 559 | 560 | //----------------------------------------------------------------------------- 561 | // Generic strlen support 562 | 563 | template 564 | size_t StringLength(const XCHAR * szString) 565 | { 566 | const XCHAR * szStr; 567 | 568 | for (szStr = szString; szStr[0] != 0; szStr++); 569 | return (szStr - szString); 570 | } 571 | 572 | //----------------------------------------------------------------------------- 573 | // Binary <-> String support 574 | 575 | template 576 | DWORD BinaryToString(XCHAR * szBuffer, size_t cchBuffer, LPCVOID pvBinary, size_t cbBinary) 577 | { 578 | LPCBYTE pbBinary = (LPCBYTE)pvBinary; 579 | 580 | // The size of the string must be enough to hold the binary + EOS 581 | if(cchBuffer < ((cbBinary * 2) + 1)) 582 | return ERROR_INSUFFICIENT_BUFFER; 583 | 584 | // Convert the string to the array of MD5 585 | // Copy the blob data as text 586 | for(size_t i = 0; i < cbBinary; i++) 587 | { 588 | *szBuffer++ = IntToHexChar[pbBinary[0] >> 0x04]; 589 | *szBuffer++ = IntToHexChar[pbBinary[0] & 0x0F]; 590 | pbBinary++; 591 | } 592 | 593 | // Terminate the string 594 | *szBuffer = 0; 595 | return ERROR_SUCCESS; 596 | } 597 | 598 | template 599 | DWORD StringToBinary(const XCHAR * szString, LPVOID pvBinary, size_t cbBinary, size_t * PtrBinary = NULL) 600 | { 601 | LPBYTE pbBinary = (LPBYTE)pvBinary; 602 | LPBYTE pbBinaryEnd = pbBinary + cbBinary; 603 | LPBYTE pbSaveBinary = pbBinary; 604 | 605 | // Verify parameter 606 | if(szString != NULL && szString[0] != 0) 607 | { 608 | // Work as long as we have at least 2 characters ready 609 | while(szString[0] != 0 && szString[1] != 0) 610 | { 611 | // Convert both to unsigned char to get rid of negative indexes produced by szString[x] 612 | BYTE StringByte0 = (BYTE)szString[0]; 613 | BYTE StringByte1 = (BYTE)szString[1]; 614 | 615 | // Each character must be within the range of 0x80 616 | if(StringByte0 > 0x80 || StringByte1 > 0x80) 617 | return ERROR_INVALID_PARAMETER; 618 | if(CharToByte[StringByte0] == 0xFF || CharToByte[StringByte1] == 0xFF) 619 | return ERROR_INVALID_PARAMETER; 620 | 621 | // Overflow check 622 | if(pbBinary >= pbBinaryEnd) 623 | return ERROR_INSUFFICIENT_BUFFER; 624 | 625 | *pbBinary++ = (CharToByte[StringByte0] << 0x04) | CharToByte[StringByte1]; 626 | szString += 2; 627 | } 628 | 629 | // Odd number of chars? 630 | if(szString[0] != 0 && szString[1] == 0) 631 | return ERROR_INVALID_PARAMETER; 632 | } 633 | 634 | // Give the length 635 | if(PtrBinary != NULL) 636 | PtrBinary[0] = pbBinary - pbSaveBinary; 637 | return ERROR_SUCCESS; 638 | } 639 | 640 | _inline size_t GetLengthOfBase64(size_t cbBinary) 641 | { 642 | size_t cchChars; 643 | size_t nBits = (cbBinary * 4); 644 | 645 | cchChars = (nBits / 3) + ((nBits % 3) ? 1 : 0); 646 | if(nBits % 3) 647 | cchChars += 3 - (nBits % 3); 648 | 649 | return cchChars; 650 | } 651 | 652 | template 653 | DWORD BinaryToBase64(LPCVOID pvBinary, size_t cbBinary, XCHAR * szBuffer, size_t cchBuffer, const char * Base64Table = Base64Table_Standard) 654 | { 655 | LPCBYTE pbBinary = (LPCBYTE)pvBinary; 656 | DWORD BitBuffer = 0; 657 | DWORD BitCount = 0; 658 | DWORD CharIndex = 0; 659 | 660 | // Verify the length of the buffer 661 | if(cchBuffer <= GetLengthOfBase64(cbBinary)) 662 | return ERROR_BUFFER_OVERFLOW; 663 | 664 | // Convert the binary buffer 665 | for(size_t i = 0; i < cbBinary; i++) 666 | { 667 | // Load 8 bits 668 | BitBuffer = (BitBuffer << 0x08) + pbBinary[i]; 669 | BitCount += 8; 670 | 671 | // Parse bits 672 | while(BitCount >= 6) 673 | { 674 | // Decrement the bit count 675 | BitCount -= 6; 676 | 677 | // The character index is the upper (BitCount - 6) bits 678 | CharIndex = BitBuffer >> BitCount; 679 | BitBuffer = BitBuffer % (1 << BitCount); 680 | 681 | // Put the new value 682 | *szBuffer++ = Base64Table[CharIndex]; 683 | } 684 | } 685 | 686 | // Put the rest 687 | if(BitCount != 0) 688 | { 689 | CharIndex = BitBuffer << (6 - BitCount); 690 | *szBuffer++ = Base64Table[CharIndex]; 691 | } 692 | 693 | // Put the remaining chars 694 | if((cbBinary % 3) != 0) 695 | *szBuffer++ = '='; 696 | if((cbBinary % 3) == 1) 697 | *szBuffer++ = '='; 698 | *szBuffer = 0; 699 | return ERROR_SUCCESS; 700 | } 701 | 702 | template 703 | DWORD Base64ToBinary(const XCHAR * szBase64, LPVOID pvBinary, size_t cbBinary, size_t * PtrSize, const char * Base64Table = Base64Table_Standard) 704 | { 705 | LPBYTE pbBinary = (LPBYTE)pvBinary; 706 | LPBYTE pbBinaryEnd = pbBinary + cbBinary; 707 | LPBYTE pbBinary0 = pbBinary; 708 | DWORD BitBuffer = 0; 709 | DWORD BitCount = 0; 710 | BYTE Base64ToBits[0x80]; 711 | BYTE OneByte; 712 | 713 | // Prepare the conversion table 714 | memset(Base64ToBits, 0xFF, sizeof(Base64ToBits)); 715 | for(BYTE i = 0; Base64Table[i] != 0; i++) 716 | { 717 | OneByte = Base64Table[i]; 718 | Base64ToBits[OneByte] = i; 719 | } 720 | 721 | // Do the decoding 722 | while(szBase64[0] != 0 && szBase64[0] != '=') 723 | { 724 | // Check for end of string 725 | if(szBase64[0] > sizeof(Base64ToBits)) 726 | return ERROR_BAD_FORMAT; 727 | if((OneByte = Base64ToBits[*szBase64++]) == 0xFF) 728 | return ERROR_BAD_FORMAT; 729 | 730 | // Put the 6 bits into the bit buffer 731 | BitBuffer = (BitBuffer << 6) | OneByte; 732 | BitCount += 6; 733 | 734 | // Flush all values 735 | while(BitCount >= 8) 736 | { 737 | // Decrement the bit count in the bit buffer 738 | BitCount -= 8; 739 | 740 | // The byte is the upper 8 bits of the bit buffer 741 | OneByte = (BYTE)(BitBuffer >> BitCount); 742 | BitBuffer = BitBuffer % (1 << BitCount); 743 | 744 | // Put the byte value 745 | if(pbBinary >= pbBinaryEnd) 746 | return ERROR_BUFFER_OVERFLOW; 747 | *pbBinary++ = OneByte; 748 | } 749 | } 750 | 751 | // Return the decoded length 752 | if(PtrSize != NULL) 753 | PtrSize[0] = (pbBinary - pbBinary0); 754 | return ERROR_SUCCESS; 755 | } 756 | 757 | //----------------------------------------------------------------------------- 758 | // Generic file path support 759 | 760 | // Retrieves the pointer to plain name and extension 761 | template 762 | XCHAR * WINAPI GetPlainName(const XCHAR * szFileName) 763 | { 764 | const XCHAR * szPlainName = szFileName; 765 | 766 | while(szFileName[0] != 0) 767 | { 768 | if(szFileName[0] == '\\' || szFileName[0] == '/') 769 | szPlainName = szFileName + 1; 770 | szFileName++; 771 | } 772 | 773 | return (XCHAR *)szPlainName; 774 | } 775 | 776 | template 777 | XCHAR * WINAPI GetFileExtension(const XCHAR * szFileName) 778 | { 779 | const XCHAR * szExtension = NULL; 780 | 781 | // We need to start searching from the plain name 782 | // Avoid: C:\$RECYCLE.BIN\File.ext 783 | szFileName = GetPlainName(szFileName); 784 | 785 | // Find the last dot in the plain file name 786 | while(szFileName[0] != 0) 787 | { 788 | if(szFileName[0] == '.') 789 | szExtension = szFileName; 790 | szFileName++; 791 | } 792 | 793 | // If not found, return the end of the file name 794 | return (XCHAR *)((szExtension != NULL) ? szExtension : szFileName); 795 | } 796 | 797 | // This function compares a string with a wildcard search string. 798 | // returns TRUE, when the string matches with the wildcard. 799 | template 800 | BOOL WINAPI CompareStringWildCard(const XCHAR * szString, const XCHAR * szWildCard) 801 | { 802 | const XCHAR * szWildCardPtr; 803 | 804 | for(;;) 805 | { 806 | // If there is '?' in the wildcard, we skip one char 807 | while(szWildCard[0] == '?') 808 | { 809 | if(szString[0] == 0) 810 | return FALSE; 811 | 812 | szWildCard++; 813 | szString++; 814 | } 815 | 816 | // Handle '*' 817 | szWildCardPtr = szWildCard; 818 | if(szWildCardPtr[0] != 0) 819 | { 820 | if(szWildCardPtr[0] == '*') 821 | { 822 | while(szWildCardPtr[0] == '*') 823 | szWildCardPtr++; 824 | 825 | if(szWildCardPtr[0] == 0) 826 | return TRUE; 827 | 828 | if(toupper(szWildCardPtr[0]) == toupper(szString[0])) 829 | { 830 | if(CompareStringWildCard(szString, szWildCardPtr)) 831 | return TRUE; 832 | } 833 | } 834 | else 835 | { 836 | if(toupper(szWildCardPtr[0]) != toupper(szString[0])) 837 | return FALSE; 838 | 839 | szWildCard = szWildCardPtr + 1; 840 | } 841 | 842 | if(szString[0] == 0) 843 | return FALSE; 844 | szString++; 845 | } 846 | else 847 | { 848 | return (szString[0] == 0) ? TRUE : FALSE; 849 | } 850 | } 851 | } 852 | 853 | //----------------------------------------------------------------------------- 854 | // Per-monitor DPI support (since Windows 10 17134) 855 | 856 | bool DPI_HighDpiSupported(); 857 | UINT DPI_GetDpiForSystem(); 858 | UINT DPI_GetDpiForWindow(HWND hWnd); 859 | int DPI_SystemMetrics(int nIndex, int nDPI = 0); 860 | 861 | //----------------------------------------------------------------------------- 862 | // Debug print and log print support 863 | 864 | void WINAPI LogToFile(LPCTSTR szFileName, LPCTSTR szFmt, va_list argList); 865 | 866 | // In debug version, shows a formatted text on debug output 867 | #if defined(_DEBUG) || defined(DBG) 868 | void _cdecl DbgV(LPCTSTR szFmt, va_list argList); 869 | void _cdecl Dbg(LPCTSTR szFmt, ...); 870 | #else 871 | _inline void _cdecl DbgV(LPCTSTR, va_list) {} 872 | _inline void _cdecl Dbg(...) {} 873 | #endif 874 | 875 | // If LOG_FILE_NAME is defined, the function sends a string to the log file 876 | #if defined(LOG_FILE_NAME) 877 | _inline void _cdecl Log(LPCTSTR szFmt, ...) 878 | { 879 | va_list argList; 880 | 881 | va_start(argList, szFmt); 882 | LogToFile(_T(LOG_FILE_NAME), szFmt, argList); 883 | va_end(argList); 884 | } 885 | #else 886 | _inline void _cdecl Log(...) {} 887 | #endif 888 | 889 | //----------------------------------------------------------------------------- 890 | // Utility function prototypes 891 | 892 | // Initialization 893 | void WINAPI InitInstance(HINSTANCE hInst = NULL, HANDLE hHeap = NULL); 894 | bool _cdecl SetLocalizedStrings(UINT nIDString, UINT nIDLocalizedString, ...); 895 | 896 | // Adds/removes backslash to/from end of path name 897 | LPTSTR WINAPI AddBackslash(LPTSTR szPathName, size_t cchPathName = MAX_PATH); 898 | LPTSTR WINAPI RemoveBackslash(LPTSTR szPathName); 899 | 900 | // String allocations 901 | LPTSTR WINAPI NewStr(LPCSTR szString, size_t cchCharsToReserve = 0); 902 | LPTSTR WINAPI NewStr(LPCWSTR szString, size_t cchCharsToReserve = 0); 903 | LPTSTR WINAPI NewStr(LPCSTR szStringBegin, LPCSTR szStringEnd); 904 | LPTSTR WINAPI NewStr(LPCWSTR szStringBegin, LPCWSTR szStringEnd); 905 | LPSTR WINAPI NewStrAnsi(LPCSTR szString, size_t cchCharsToReserve = 0); 906 | LPSTR WINAPI NewStrAnsi(LPCWSTR szString, size_t cchCharsToReserve = 0); 907 | 908 | // Uses static buffer if enough space, otherwise allocates new 909 | LPSTR WINAPI NewStrWithBuff(LPSTR szStaticBuff, size_t cchStaticBuff, LPCSTR szSrc); 910 | LPWSTR WINAPI NewStrWithBuff(LPWSTR szStaticBuff, size_t cchStaticBuff, LPCWSTR szSrc); 911 | 912 | // Creates the full path from a directory and file name 913 | // Handles directory names with or without ending backslashes 914 | // Returns the pointer to plain file name 915 | // The caller needs to free the path using delete [] 916 | LPTSTR WINAPI CreateFullPath(LPCTSTR szDirectory, LPCTSTR szSubDir, LPCTSTR szPlainName); 917 | 918 | // Adds a new string to the existing one. The existing must have been 919 | // allocated by new, the result must be freed using "FreeAppendedString", when no longer needed. 920 | // The "szString" may be NULL. 921 | LPTSTR WINAPI AppendString(LPTSTR szString, LPCTSTR szAdd, LPCTSTR szSeparator = _T("\r\n")); 922 | void WINAPI FreeAppendedString(LPTSTR szString); 923 | 924 | // Browses for a file. The initial dir and/or the file may be 925 | // entered by a string or by a control ID. 926 | //BOOL BrowseForFile(HWND hParent, LPTSTR szDir, LPTSTR szFile, UINT nIDTitle, UINT nIDFilters); 927 | void WINAPI InitOpenFileName(LPOPENFILENAME pOFN); 928 | BOOL WINAPI GetOpenFileNameRc(HWND hWndParent, LPOPENFILENAME pOFN); 929 | BOOL WINAPI GetSaveFileNameRc(HWND hWndParent, LPOPENFILENAME pOFN); 930 | 931 | // Browses for a folder. The folder is stored into the "nIDEdit" 932 | // control 933 | BOOL WINAPI BrowseForDirectory(HWND hDlg, LPTSTR szDir, size_t cchDir, UINT nIDTitle); 934 | 935 | // Centers a window by its parent or screen 936 | void WINAPI CenterWindow(HWND hWnd); 937 | void WINAPI CenterWindowToParent(HWND hWnd); 938 | 939 | BOOL WINAPI CompareWindowsTexts(HWND hDlg, UINT nID1, UINT nID2, UINT nIDMsg); 940 | 941 | // Creates a HDROP structure for the file. 942 | // The caller must free it using GlobalFree. 943 | HDROP WINAPI CreateDropForDirectory(LPCTSTR szDirName, PLARGE_INTEGER pFileSize); 944 | HDROP WINAPI CreateDropForFile(LPCTSTR szFileName); 945 | HDROP WINAPI CreateCopyOfHDROP(HDROP hDrop); 946 | 947 | // Multistring support 948 | LPTSTR WINAPI CreateMultiString(bool bEosSeparator); 949 | LPTSTR WINAPI AddStringToMultiString(LPTSTR szMultiString, LPCTSTR szString); 950 | size_t WINAPI GetMultiStringLength(LPCTSTR szMultiString); 951 | DWORD WINAPI GetMultiStringCount(LPCTSTR szMultiString); 952 | void WINAPI FreeMultiString(LPTSTR szMultiString); 953 | 954 | // Converts a GUID to registry string format (i.e. {XXXXXXXX-XXXX-...}) 955 | int WINAPI GuidToString(LPGUID pGuid, LPTSTR szBuffer, size_t cchBuffer); 956 | bool WINAPI StringToGuid(LPCTSTR szString, LPGUID pGuid); 957 | 958 | // Enables/disables a group of dialog items by their ID. 959 | // The ID list must end with 0. 960 | int _cdecl ShowDlgItems(HWND hDlg, int nCmdShow, ...); 961 | int _cdecl EnableDlgItems(HWND hDlg, BOOL bEnable, ...); 962 | 963 | // Enables a privilege to the current process 964 | DWORD WINAPI EnablePrivilege(LPCTSTR szPrivilegeName); 965 | 966 | // Gets the rectangle of a dialog's template 967 | BOOL WINAPI GetDialogRect(HWND hParent, UINT nIDDlgTemplate, RECT & rect); 968 | 969 | // Get the title of the page from the dialog template 970 | DWORD WINAPI GetDialogTitleFromTemplate(HINSTANCE hInst, LPCTSTR szDlgTemplate, LPTSTR szTitle, size_t cchTitle); 971 | 972 | // Retrieves the error text. The caller must free the text using 973 | // delete [] szText; 974 | #define ERRT_APPEND_ERROR_CODE 0x01 // Append " (error code: %u)" 975 | #define ERRT_APPEND_TWO_NEWLINES 0x02 // Append two newlines instead of one 976 | #define ERRT_APPEND_ERROR_MSG 0x04 // Append error message 977 | #define ERRT_APPEND_ENDING_DOT 0x08 // Append a dot at the end 978 | DWORD WINAPI GetErrorText(LPTSTR szBuffer, size_t ccBuffer, DWORD dwErrCode); 979 | LPTSTR WINAPI GetErrorText(DWORD dwErrCode); 980 | LPTSTR WINAPI AppendErrorText(LPTSTR szBuffer, size_t ccBuffer, DWORD dwErrCode, DWORD dwFlags); 981 | 982 | // Conversion from KeybCS2 to Unicode and UTF-8 983 | size_t KeybCS2ToUnicode(const char * lpKeybCS2, size_t cbKeybCS2, LPWSTR szBuffer, size_t ccBuffer); 984 | size_t KeybCS2ToUTF8(const char * lpKeybCS2, size_t cbKeybCS2, LPSTR szBuffer, size_t ccBuffer); 985 | 986 | // Fills the module version 987 | DWORD WINAPI GetModuleVersion(LPCTSTR szModuleName, ULARGE_INTEGER * pVersion); 988 | DWORD WINAPI GetModuleVersion(HMODULE hModule, ULARGE_INTEGER * pVersion); 989 | 990 | // Returns a localized string for a few IDS_XXX strings. 991 | LPCTSTR WINAPI GetString(UINT_PTR nIDString); 992 | 993 | // Returns the language of current Windows installation 994 | // (Not the value set by the user in Regional Settings) 995 | USHORT WINAPI GetSystemLanguage(); 996 | 997 | // Fills the buffer by the current user's specific directory name 998 | DWORD WINAPI GetShellFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath); 999 | 1000 | // Gets the widths of the window borders (non-client area) 1001 | // and stores them to the "pRect" parameter 1002 | void WINAPI GetWindowBorders(HWND hWnd, LPRECT pRect); 1003 | 1004 | // Retrieves the Windows version (see OSVER_WINDOWS_XXX) 1005 | DWORD WINAPI GetWindowsVersion(POSVERSIONINFO pOsvi = NULL); 1006 | 1007 | // Retrieves the Windows build number (see OSBUILD_WINDOWS_XXX) 1008 | DWORD WINAPI GetWindowsBuildNumber(); 1009 | 1010 | // Initializes the dialog controls, like combo boxes and list boxes. 1011 | DWORD WINAPI InitDialogControls(HWND hDlg, LPCTSTR lpszResourceName); 1012 | 1013 | // Returns true if the user runs as administrator (or elevated in Vista) 1014 | BOOL WINAPI IsAdministrator(); 1015 | 1016 | // REMOVED: 1017 | // This function decodes the WM_COMMAND message. If another message, this function 1018 | // returns FALSE. If it is a WM_COMMAND, it decodes the motification code, and control ID 1019 | // (Control ID is 0 for a menu and 1 for an accelerator). 1020 | //BOOL IsCommandMessage(UINT uMsg, WPARAM wParam, UINT & nNotify, UINT_PTR & nIDCtrl); 1021 | #define WMC_NOTIFY(wParam) HIWORD(wParam) 1022 | #define WMC_CTRLID(wParam) LOWORD(wParam) 1023 | 1024 | // Checks of the directory is accessible at least for listin files 1025 | BOOL WINAPI IsDirectoryAccessible(const LPTSTR szDirectory); 1026 | 1027 | // Sets the timeout for message box, in milliseconds 1028 | void WINAPI SetMessageBoxTimeout(DWORD dwTimeout); 1029 | 1030 | // Shows a message box that also includes check box 1031 | int WINAPI MessageBoxWithCheckBox( 1032 | HWND hWndParent, 1033 | LPCTSTR szCaption, 1034 | LPCTSTR szMessage, 1035 | LPCTSTR szCheckText, 1036 | bool * pbCheckValue, 1037 | UINT uType); 1038 | 1039 | // Shows a message box that also includes check box. 1040 | // This one uses string resource IDs rather than texts. 1041 | int WINAPI MessageBoxWithCheckBox( 1042 | HWND hWndParent, 1043 | UINT nIDCaption, 1044 | UINT nIDMessage, 1045 | UINT nIDCheckText, 1046 | bool * pbCheckValue, 1047 | UINT uType); 1048 | 1049 | // Shows a message box using resource strings 1050 | int WINAPI MessageBoxRcV(HWND hParent, UINT_PTR nIDCaption, UINT_PTR nIDFormat, va_list argList); 1051 | int _cdecl MessageBoxRc(HWND hParent, UINT_PTR nIDCaption, UINT_PTR nIDFormat, ...); 1052 | 1053 | // Shows a question message box with "Yes - Yes All - No - Cancel" buttons 1054 | int WINAPI MessageBoxYANCV(HWND hWndParent, UINT_PTR nIDTitle, UINT_PTR nIDFormat, va_list argList); 1055 | int _cdecl MessageBoxYANC(HWND hWndParent, UINT_PTR nIDTitle, UINT_PTR nIDFormat, ...); 1056 | 1057 | // Shows a message box with appended error code text 1058 | // "Failed to open the file %s\nAccess denied" 1059 | // Returns the error code passed to dwErrCode 1060 | DWORD WINAPI MessageBoxErrorV(HWND hParent, UINT_PTR nIDFormat, DWORD dwErrCode, va_list argList); 1061 | DWORD _cdecl MessageBoxError(HWND hParent, UINT_PTR nIDFormat, DWORD dwErrCode = ERROR_SUCCESS, ...); 1062 | 1063 | // Sets an icon to the dialog 1064 | void WINAPI SetDialogIcon(HWND hDlg, UINT nIDIcon); 1065 | 1066 | // Ensures that the path exists. 1067 | DWORD WINAPI ForcePathExist(LPCTSTR szPathName, BOOL bIsDirectory = FALSE); 1068 | 1069 | // Returns the domain name for currently logged on user 1070 | DWORD WINAPI GetDomainName(LPTSTR szText, LPDWORD pdwSize); 1071 | 1072 | // Searches all available processes by given name. 1073 | // If the name is found, the function returns the process ID. 1074 | #define INVALID_PROCESS_ID 0xFFFFFFFF 1075 | 1076 | typedef struct _FIND_PROCESS_PARAMS 1077 | { 1078 | LPTSTR szExeName; 1079 | size_t cchExeName; 1080 | DWORD dwProcessId; 1081 | } FIND_PROCESS_PARAMS, *PFIND_PROCESS_PARAMS; 1082 | 1083 | typedef bool (ENUM_PROCESS_PROC)(PFIND_PROCESS_PARAMS pFindParams, LPVOID lpParameter); 1084 | 1085 | bool WINAPI EnumAllProcesses(ENUM_PROCESS_PROC PfnEnumProc, LPVOID lpParameter = NULL); 1086 | bool WINAPI FindProcessByName(LPCTSTR szExeName, PFIND_PROCESS_PARAMS pFindParams = NULL); 1087 | 1088 | // RadioButton functions 1089 | DWORD WINAPI GetRadioValue(HWND hDlg, UINT nIDFirst); 1090 | void WINAPI SetRadioValue(HWND hDlg, UINT nIDFirst, UINT nValue); 1091 | 1092 | // CheckBox functions 1093 | DWORD WINAPI GetCheckBoxMask(HWND hDlg, UINT nIDFirst); 1094 | void WINAPI SetCheckBoxMask(HWND hDlg, UINT nIDFirst, DWORD dwMask, DWORD dwEnabled); 1095 | 1096 | // Edit functions 1097 | BOOL WINAPI SetEditCueBanner(HWND hEdit, LPCTSTR szText); 1098 | BOOL WINAPI SetEditCueBanner(HWND hEdit, UINT nIDText); 1099 | BOOL WINAPI SetEditCueBanner(HWND hDlg, UINT nIDEdit, LPCTSTR szText); 1100 | BOOL WINAPI SetEditCueBanner(HWND hDlg, UINT nIDEdit, UINT nIDText); 1101 | 1102 | // ComboBox functions 1103 | BOOL WINAPI SetComboBoxCueBanner(HWND hCombo, LPCTSTR szText); 1104 | BOOL WINAPI SetComboBoxCueBanner(HWND hCombo, UINT nIDText); 1105 | BOOL WINAPI SetComboBoxCueBanner(HWND hDlg, UINT nIDCombo, LPCTSTR szText); 1106 | BOOL WINAPI SetComboBoxCueBanner(HWND hDlg, UINT nIDCombo, UINT nIDText); 1107 | 1108 | // URL cursor functions 1109 | HCURSOR WINAPI CreateUrlPointCursor(); 1110 | HCURSOR WINAPI CreateUrlWaitCursor(); 1111 | 1112 | // URL Buttons functions 1113 | BOOL WINAPI ClickURLButton(HWND hButton); 1114 | BOOL WINAPI DrawURLButton(HWND hDlg, LPDRAWITEMSTRUCT dis); 1115 | DWORD WINAPI InitURLButton(HWND hDlg, UINT nIDCtrl, BOOL bBigFont); 1116 | DWORD WINAPI InitURLButtons(HWND hDlg); 1117 | BOOL WINAPI IsURLButton(HWND hWnd); 1118 | 1119 | // Functions related to ListView columns and items 1120 | #define ListView_GetItemA(hwnd, pitem) (BOOL)SNDMSG((hwnd), LVM_GETITEMA, 0, (LPARAM)(LV_ITEMA *)(pitem)) 1121 | #define ListView_SetItemA(hwnd, pitem) (BOOL)SNDMSG((hwnd), LVM_SETITEMA, 0, (LPARAM)(const LV_ITEMA *)(pitem)) 1122 | #define ListView_InsertItemA(hwnd, pitem) (int)SNDMSG((hwnd), LVM_INSERTITEMA, 0, (LPARAM)(const LV_ITEMA *)(pitem)) 1123 | 1124 | int WINAPI ListView_CreateColumns(HWND hList, TListViewColumns * pColumns); 1125 | void WINAPI ListView_ResizeColumns(HWND hList, TListViewColumns * pColumns, int nMinColumnWidth = 0); 1126 | void WINAPI ListView_SetSortArrow(HWND hListView, int nColumn, bool bAscending); 1127 | int WINAPI InsertLVItem(HWND hList, int nIcon, LPCTSTR szText, LPARAM lParam); 1128 | int WINAPI ListView_SetSubItem(HWND hList, int nItem, int nSubItem, LPCTSTR szText); 1129 | LPARAM WINAPI ListView_GetItemParam(HWND hList, int nItem); 1130 | BOOL WINAPI ListView_SetItemParam(HWND hList, int nItem, LPARAM lParam); 1131 | 1132 | // TabControl support 1133 | DWORD WINAPI TabCtrl_Create(HWND hTabCtrl, PVOID pPropSheetHeader); 1134 | BOOL WINAPI TabCtrl_Resize(HWND hTabCtrl, int x, int y, int cx, int cy); 1135 | BOOL WINAPI TabCtrl_NewDpi(HWND hTabCtrl); 1136 | BOOL WINAPI TabCtrl_GetIdealChildRect(HWND hTabCtrl, LPRECT pRect); 1137 | int WINAPI TabCtrl_SelectNextPage(HWND hTabCtrl, BOOL bNextPage); 1138 | void WINAPI TabCtrl_SelectPageByIndex(HWND hTabCtrl, UINT nPageIndex); 1139 | BOOL WINAPI TabCtrl_SelectPageByID(HWND hTabCtrl, LPCTSTR pszPageID); 1140 | HWND WINAPI TabCtrl_GetSelectedPage(HWND hTabCtrl); 1141 | HWND WINAPI TabCtrl_IsTabControl(HWND hTabCtrl); 1142 | BOOL WINAPI TabCtrl_IsDialogMessage(HWND hDlg, HWND hTabCtrl, LPMSG pMsg); 1143 | INT_PTR WINAPI TabCtrl_HandleMessages(HWND hTabControl, UINT uMsg, WPARAM wParam, LPARAM lParam); 1144 | 1145 | // Reads line from text file. The file must be opened in text mode 1146 | // Returns -1 if end of file, otherwise number of characters read 1147 | int WINAPI ReadLine(FILE * fp, LPTSTR szBuffer, size_t ccBuffer); 1148 | 1149 | // Replaces the file name with the another one 1150 | DWORD WINAPI ReplaceFileName(LPTSTR szFullPath, LPCTSTR szPlainName); 1151 | 1152 | // Replaces the file extension with another one. 1153 | DWORD WINAPI ReplaceFileExt(LPTSTR szFileName, LPCTSTR szNewExt); 1154 | 1155 | // Like sprintf, but the format string is taken from resources 1156 | int _cdecl rsvprintf(LPTSTR szBuffer, size_t nMaxChars, UINT nIDFormat, va_list argList); 1157 | int _cdecl rsprintf(LPTSTR szBuffer, size_t nMaxChars, UINT nIDFormat, ...); 1158 | 1159 | // Recalculates a screen window position (such as retrieved by GetWindowRect) 1160 | // to the client coordinates of the window "hWnd". 1161 | void WINAPI GetWindowScreenRect(HWND hWnd, LPRECT pRect); 1162 | void WINAPI ScreenRectToClientRect(HWND hWnd, LPRECT pRect); 1163 | void WINAPI ClientRectToScreenRect(HWND hWnd, LPRECT pRect); 1164 | 1165 | // Retrieves the rectangle of a window relative to its parent 1166 | BOOL WINAPI GetWindowRectParentRelative(HWND hWnd, LPRECT pRect); 1167 | BOOL WINAPI GetClientRectScreenRelative(HWND hWnd, LPRECT pRect); 1168 | 1169 | // Sets a bold font for a dialog control 1170 | DWORD WINAPI SetBoldFont(HWND hDlg, UINT nIDCtrl, int nPercentSize = 0); 1171 | 1172 | // Retrieves a window text and stores it into a string 1173 | LPTSTR WINAPI NewStr(HWND hWnd, size_t cchCharsToReserve = 0); 1174 | 1175 | // Sets a window text from resource 1176 | int WINAPI SetWindowTextRcVA(HWND hWnd, UINT nIDText, va_list argList); 1177 | int _cdecl SetWindowTextRc(HWND hWnd, UINT nIDText, ...); 1178 | 1179 | // Shows a systray baloon or a timed messagebox 1180 | BOOL _cdecl ShowSystrayBaloon(HWND hDlg, UINT nIDIcon, UINT nIDTitle, UINT nIDText, ...); 1181 | 1182 | // Verifies if the user's password is valid. 1183 | BOOL WINAPI VerifyUserPassword(LPTSTR szUserName, LPTSTR szDomain, LPTSTR szPassword); 1184 | 1185 | // Finds a path to WinDbg debugger 1186 | // Optionally sets the WINDBG_DIR environment variable 1187 | #define WDBG_PATH_SET_VARIABLE 0x0001 1188 | #define WDBG_PATH_INCLUDE_FILENAME 0x0002 1189 | #define WDBG_PATH_CHECK_WINDBGX 0x0004 1190 | bool WINAPI FindWindbgPath(LPTSTR szBuffer, size_t cchMaxChars, DWORD dwFlags = 0); 1191 | 1192 | // API resolver 1193 | DWORD WINAPI ResolveAPI(LPCTSTR szModuleName, LPCSTR szApiName, FARPROC * PfnProcAddress); 1194 | DWORD _cdecl ResolveAPIs(LPCTSTR szModuleName, ...); 1195 | 1196 | // Wow64 support 1197 | BOOL WINAPI DisableWoW64FsRedirection(PVOID * ppvOldValue); 1198 | BOOL WINAPI RevertWoW64FsRedirection(PVOID pvOldValue); 1199 | bool WINAPI IsWow64Process(HANDLE hProcess = GetCurrentProcess()); 1200 | void WINAPI GetWoW64SystemInfo(LPSYSTEM_INFO lpSystemInfo); 1201 | bool WINAPI Is64BitModule(HMODULE hMod); 1202 | bool WINAPI Is64BitWindows(); 1203 | 1204 | // Writes the whole resource to a file 1205 | DWORD WriteResourceToFile(LPCTSTR szFileName, LPCTSTR szResourceType, LPCTSTR szResID); 1206 | 1207 | // Writes the dump file after crash 1208 | LONG WINAPI WriteDumpFile(HWND hWndParent, PEXCEPTION_POINTERS ExceptionPointers); 1209 | 1210 | bool WINAPI IsRunningInWine(); 1211 | 1212 | #endif // __UTILS_H__ 1213 | --------------------------------------------------------------------------------