17 HRESULT res = ::CoCreateGuid (&guid);
29 _T (
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"),
30 guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1],
31 guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
32 guid.Data4[6], guid.Data4[7]);
39 SYSTEMTIME systemTime;
48 SYSTEMTIME systemTime;
59 _T (
"%04d/%02d/%02d %02d:%02d:%02d.%03d"), systemTime.wYear,
60 systemTime.wMonth, systemTime.wDay, systemTime.wHour,
61 systemTime.wMinute, systemTime.wSecond, systemTime.wMilliseconds);
71 BOOL ret = ::SystemTimeToFileTime (&systemTime, &fileTime);
73 ULARGE_INTEGER response{ 0, 0 };
77 response.HighPart = fileTime.dwHighDateTime;
78 response.LowPart = fileTime.dwLowDateTime;
86 SYSTEMTIME systemlTime{ 0, 0, 0, 0, 0, 0, 0, 0 };
88 ::FileTimeToSystemTime (&fileTime, &systemlTime);
99 LPBYTE lpbyString, DWORD dwLength,
TString& response)
101 BOOL bResponse = FALSE;
105 if (::CryptBinaryToString (
106 lpbyString, dwLength, CRYPT_STRING_BASE64, NULL, &dwBuffer))
108 lptszBuffer =
new TCHAR[dwBuffer +
sizeof (TCHAR)];
109 if (::CryptBinaryToString (
110 lpbyString, dwLength, CRYPT_STRING_BASE64, lptszBuffer, &dwBuffer))
112 response = lptszBuffer;
116 delete[] lptszBuffer;
124 BOOL bResponse = FALSE;
126 if (lpbyBuffer == NULL)
128 bResponse = ::CryptStringToBinary (
129 source.
Ctr (), source.
Len (), CRYPT_STRING_BASE64, NULL, &dwBuffer,
134 bResponse = ::CryptStringToBinary (
135 source.
Ctr (), source.
Len (), CRYPT_STRING_BASE64, lpbyBuffer,
136 &dwBuffer, NULL, NULL);
147 LPTCH lptchEnv = ::GetEnvironmentStrings ();
148 if (lptchEnv == NULL)
return response;
150 LPTSTR lptszVariable = (LPTSTR)lptchEnv;
152 while (*lptszVariable)
154 TString string (lptszVariable);
155 response.
Add (
string);
156 lptszVariable += (lstrlen (lptszVariable) + (SIZE_T)1);
159 FreeEnvironmentStrings (lptchEnv);
169 dwRet = ::GetEnvironmentVariable (lpctszKeyword, NULL, 0);
170 if (dwRet == 0)
return enpty;
173 ::GetEnvironmentVariable (lpctszKeyword, response.
Ptr (), dwRet);
181 TCHAR tszBuffer[MAX_PATH];
183 DWORD dwSize = ::GetPrivateProfileString (lpctszSection, lpctszKeyword, _T (
""), tszBuffer, MAX_PATH, lpctszIniFile);
187 response = tszBuffer;
199DWORD
Utility::ReadIniFile (LPCTSTR lpctszIniFile, LPCTSTR lpctszSection, LPCTSTR lpctszKeyword, DWORD dwDefault)
201 return ::GetPrivateProfileInt (lpctszSection, lpctszKeyword, dwDefault, lpctszIniFile);
206 return ::WritePrivateProfileString (lpctszSection, lpctszKeyword, strValue.
Ctr (), lpctszIniFile);
215 return ::WritePrivateProfileString (lpctszSection, lpctszKeyword, strValue.
Ctr (), lpctszIniFile);
222 DWORD dwHashSize = 16;
224 CHAR szDigits[] =
"0123456789ABCDEF";
229 ret = ::CryptAcquireContext (&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
232 ret = ::CryptCreateHash (hProv, CALG_MD5, 0, 0, &hHash);
235 ret = ::CryptHashData (hHash, lpbyData, dwSize, 0);
238 ret = CryptGetHashParam (hHash, HP_HASHVAL, byHash, &dwHashSize, 0);
242 for (DWORD i = 0; i < dwHashSize; i++)
244 CHAR cData1 = szDigits[byHash[i] >> 4];
245 CHAR cData2 = szDigits[byHash[i] & 0x0f];
246 lpbyMD5[n++] = cData1;
247 lpbyMD5[n++] = cData2;
250 ret = ::CryptDestroyHash (hHash);
253 ret = ::CryptReleaseContext (hProv, 0);
264 DWORD dwHashSize = 16;
266 const CHAR cszDigits[] =
"0123456789ABCDEF";
268 BYTE byBuffer[8192]{ 0 };
274 ret = checkFile.
Create (lpctszFileName, GENERIC_READ, 0, OPEN_EXISTING);
277 ret = ::CryptAcquireContext (&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
280 ret = ::CryptCreateHash (hProv, CALG_MD5, 0, 0, &hHash);
283 while ((dwReadSize = checkFile.
Read (byBuffer, sizeof (byBuffer))) > 0)
285 ret = ::CryptHashData (hHash, byBuffer, dwReadSize, 0);
289 ret = checkFile.
Close ();
292 ret = CryptGetHashParam (hHash, HP_HASHVAL, byHash, &dwHashSize, 0);
296 for (DWORD i = 0; i < dwHashSize; i++)
298 const CHAR ccData1 = cszDigits[byHash[i] >> 4];
299 const CHAR ccData2 = cszDigits[byHash[i] & 0x0f];
300 lpbyMD5[n++] = ccData1;
301 lpbyMD5[n++] = ccData2;
304 ret = ::CryptDestroyHash (hHash);
307 ret = ::CryptReleaseContext (hProv, 0);
ファイルIOに関するWindowsAPIを集約したクラス
ファイルIOに関するWindowsAPIを集約したクラス
BOOL APIENTRY Create(LPCTSTR lpctszFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition)
ファイルを作成、オープンします。
BOOL APIENTRY Close()
使用しなくなったハンドルはこれでクローズします。
DWORD APIENTRY Read(LPVOID lpvBuffer, DWORD dwSize) const
HANDLEを使ってデータを読み込みます。
文字列に関するWindowsAPIを集約したクラス
TString &APIENTRY Format(LPCTSTR format,...)
フォーマットに従ってパラメータを文字列化します。
INT APIENTRY Len() const
内部で確保している文字列数を取得します。
LPCTSTR APIENTRY Ctr() const
内部で確保している文字列ポインタを取得します。
LPTSTR APIENTRY Ptr() const
内部で確保している文字列ポインタを取得します。
static BOOL APIENTRY Base64Decode(TString &source, LPBYTE lpbyBuffer, DWORD &dwBuffer)
BASE64データをデコード
static const TString APIENTRY MakeGUID()
GUIDの作成
static skeleton::Array< TString > APIENTRY GetEnvironments()
環境変数の取得
static ULARGE_INTEGER APIENTRY GetLocalTimeQuad()
ローカル時間を64ビット値で取得
static BOOL APIENTRY CreateMD5(LPBYTE lpbyData, DWORD dwSize, LPBYTE lpbyMD5)
データからMD5を計算
static const GUID APIENTRY CreateGUID()
GUIDの作成
static BOOL APIENTRY ReadIniFile(LPCTSTR lpctszIniFile, LPCTSTR lpctszSection, LPCTSTR lpctszKeyword, TString &response)
設定フィルの読み込み
static TString APIENTRY GetEnv(LPCTSTR lpctszKeyword)
環境変数の取得
static BOOL APIENTRY Base64Encode(LPBYTE lpbyString, DWORD dwLength, TString &response)
BASE64でデータをエンコード
static SYSTEMTIME APIENTRY GetLocalTime()
ローカル時間の取得
static VOID APIENTRY GetSystemInfo(SYSTEM_INFO &systemInfo)
システム情報を取得します。
static TString APIENTRY GetFormatTime(const SYSTEMTIME &systemTime)
SYSTEMTIME構造体の値を文字列化
static SYSTEMTIME APIENTRY GetTimeByFileTime(const FILETIME &fileTime)
FILETIME型からSYSTEMTIMEを取得
static BOOL APIENTRY WriteIniFile(LPCTSTR lpctszIniFile, LPCTSTR lpctszSection, LPCTSTR lpctszKeyword, TString &strValue)
設定フィルの書き込み
static SYSTEMTIME APIENTRY GetSystemTime()
システム時間の取得
VOID APIENTRY Add(T &item)
Array<T>へ値を追加