13 #pragma managed( push, off )    28     void UtilNotifyFatalError( 
wchar_t const* pszFileName, 
wchar_t const* pszFuncName, UINT uLineNumber ) noexcept {
    30         wchar_t szExeName[ MAX_PATH ];
    34         wchar_t szFileName[ MAX_PATH ];
    38         DWORD dwProcessId = ::GetCurrentProcessId();
    41         DWORD dwThreadId = ::GetCurrentThreadId();
    44         wchar_t szBuffer[ 2048 ];
    45         ::swprintf_s( szBuffer, L
"★以下の場所で致命的エラーが発生したためプログラムを終了します。\n"    61         int nResult = ::MessageBoxW( 
nullptr, szBuffer, L
"★致命的エラー", MB_OKCANCEL | MB_ICONHAND );
    62         if ( IDOK == nResult ) {
    75             wchar_t const* pszReason = 
nullptr;
    77             case DLL_PROCESS_ATTACH: pszReason = L
"プロセスアタッチ"; 
break;
    78             case DLL_THREAD_ATTACH:  pszReason = L
"スレッドアタッチ"; 
break;
    79             case DLL_THREAD_DETACH:  pszReason = L
"スレッドデタッチ"; 
break;
    80             case DLL_PROCESS_DETACH: pszReason = L
"プロセスデタッチ"; 
break;
    84             if ( 
nullptr == pszReason ) {
    90             wchar_t szExeFile[ MAX_PATH ];
    94             wchar_t szPath[ MAX_PATH ];
    95             ::GetModuleFileNameW( hInstance, szPath, MAX_PATH );
    98             DWORD dwProcessId = ::GetCurrentProcessId();
   101             DWORD dwThreadId = ::GetCurrentThreadId();
   104             OutputDebugFormat( L
"★%s:[%04X:%04X] %s, %s\n", pszReason, dwProcessId, dwThreadId, szExeFile, szPath );
   112         wchar_t szExeFile[ MAX_PATH ];
   116         DWORD dwProcessId = ::GetCurrentProcessId();
   119         DWORD dwThreadId = ::GetCurrentThreadId();
   122         OutputDebugFormat( L
"▼コンストラクタ:[%04X:%04X] %s!%s\n", dwProcessId, dwThreadId, szExeFile, pszFuncName );
   129         wchar_t szExeFile[ MAX_PATH ];
   133         DWORD dwProcessId = ::GetCurrentProcessId();
   136         DWORD dwThreadId = ::GetCurrentThreadId();
   139         OutputDebugFormat( L
"▲デストラクタ:[%04X:%04X] %s!%s\n", dwProcessId, dwThreadId, szExeFile, pszFuncName );
   144     int ShowMessage( 
wchar_t const* pszMessage, HWND hWnd, UINT uType ) noexcept {
   149             wchar_t szCaption[ MAX_PATH ] = L
"メッセージ";
   150             if ( 
nullptr != hWnd ) {
   152                 ::GetWindowTextW( hWnd, szCaption, MAX_PATH );
   156             result = ::MessageBoxW( hWnd, pszMessage, szCaption, uType );
   169             if ( 
nullptr == pszFormat ) {
   176             va_start( vaArgs, pszFormat );
   179             wchar_t szBuffer[ MAX_PATH ];
   189             ::OutputDebugStringW( szBuffer );
   195     bool ExpandFormatArgs( 
wchar_t* pszBuffer, 
size_t uSize, 
wchar_t const* pszFormat, va_list vaArgs ) noexcept {
   200             if ( 
nullptr == pszBuffer ) {
   205             else if ( 
nullptr == pszFormat ) {
   210             else if ( 0 >= ::vswprintf_s( pszBuffer, uSize, pszFormat, vaArgs ) ) {
   227         wchar_t const* result = 
nullptr;
   230             if ( 
nullptr == pszBuffer ) {
   236             ::GetModuleFileNameW( 
nullptr, pszBuffer, static_cast< DWORD >( uSize ) );
   250         wchar_t const* result = 
nullptr;
   253             if ( 
nullptr == pszBuffer ) {
   259             wchar_t szPath[ MAX_PATH ];
   263             result = 
GetDirPath( pszBuffer, uSize, szPath );
   274         wchar_t const* result = 
nullptr;
   277             if ( 
nullptr == pszBuffer ) {
   283             wchar_t szPath[ MAX_PATH ];
   296     wchar_t const* 
GetDirPath( 
wchar_t* pszBuffer, 
size_t uSize, 
wchar_t const* pszPath ) noexcept {
   298         wchar_t const* result = 
nullptr;
   301             if ( 
nullptr == pszBuffer ) {
   306             else if ( 
nullptr == pszPath ) {
   312             wchar_t szDrive[ _MAX_DRIVE ];
   313             wchar_t szDir  [ _MAX_DIR ];
   314             wchar_t szFName[ _MAX_FNAME ];
   315             wchar_t szExt  [ _MAX_EXT ];
   316             ::_wsplitpath_s( pszPath, szDrive, szDir, szFName, szExt );
   319             ::swprintf_s( pszBuffer, uSize, L
"%s%s", szDrive, szDir );
   331     wchar_t const* 
GetFileName( 
wchar_t* pszBuffer, 
size_t uSize, 
wchar_t const* pszPath ) noexcept {
   333         wchar_t const* result = 
nullptr;
   336             if ( 
nullptr == pszBuffer ) {
   341             else if ( 
nullptr == pszPath ) {
   347             wchar_t szDrive[ _MAX_DRIVE ];
   348             wchar_t szDir  [ _MAX_DIR ];
   349             wchar_t szFName[ _MAX_FNAME ];
   350             wchar_t szExt  [ _MAX_EXT ];
   351             ::_wsplitpath_s( pszPath, szDrive, szDir, szFName, szExt );
   354             ::swprintf_s( pszBuffer, uSize, L
"%s%s", szFName, szExt );
   366     wchar_t const* 
GetModuleName( HINSTANCE hInstance, 
wchar_t* pszBuffer, 
size_t uSize ) noexcept {
   368         wchar_t const* result = 
nullptr;
   371             static wchar_t szPath[ MAX_PATH ];
   372             ::GetModuleFileNameW( hInstance, szPath, MAX_PATH );
   378             if ( 
nullptr != pszBuffer ) {
   380                 ::wcscpy_s( pszBuffer, uSize, szPath );
   400                 ch1 = ::towlower( ch1 );
   401                 ch2 = ::towlower( ch2 );
   425             if ( 
nullptr == pszString ) {
   432                 wchar_t ch2 = *pszString++;
   433                 if ( L
'\0' == ch2 ) {
   457             HMONITOR hMonitor = ::MonitorFromWindow( hWnd, MONITOR_DEFAULTTONEAREST );
   458             if ( 
nullptr == hMonitor ) {
   464             MONITORINFO sMonitorInfo = { 
sizeof( MONITORINFO ) };
   465             if ( 0 == ::GetMonitorInfo( hMonitor, &sMonitorInfo ) ) {
   471             int nWidth  = ( sMonitorInfo.rcWork.right  - sMonitorInfo.rcWork.left );
   472             int nHeight = ( sMonitorInfo.rcWork.bottom - sMonitorInfo.rcWork.top );
   475             int  nLeft    = sMonitorInfo.rcWork.left;
   476             int  nTop     = sMonitorInfo.rcWork.top;
   477             bool bFailure = 
false;
   484             default:                      bFailure = 
true;                
break; 
   494             ::SetWindowPos( hWnd, HWND_TOP, nLeft, nTop, nWidth, nHeight, ( SWP_NOACTIVATE | SWP_SHOWWINDOW ) );
   495             ::UpdateWindow( hWnd );
   512             HANDLE hSnapProcess = ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
   513             if ( 
nullptr == hSnapProcess ) {
   519             PROCESSENTRY32W sProcessEntry = { 
sizeof( PROCESSENTRY32 ) };
   520             bool            bResult       = ( 0 != ::Process32FirstW( hSnapProcess, &sProcessEntry ) );
   521             for ( ; !result && bResult; bResult = ( 0 != ::Process32NextW( hSnapProcess, &sProcessEntry ) ) ) {
   523                 HANDLE hSnapModule = ::CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, sProcessEntry.th32ProcessID );
   524                 if ( 
nullptr == hSnapModule ) {
   530                 MODULEENTRY32W sModuleEntry = { 
sizeof( MODULEENTRY32 ) };
   531                 bool           bResult      = ( 0 != ::Module32FirstW( hSnapModule, &sModuleEntry ) );
   532                 for ( ; bResult; bResult = ( 0 != ::Module32NextW( hSnapModule, &sModuleEntry ) ) ) {
   534                     if ( 0 == ::_wcsicmp( pszPath, sModuleEntry.szExePath ) ) {
   536                         result = sProcessEntry.th32ProcessID;
   548 #pragma managed( pop ) LIB_COMMON_API void UtilNotifyDllMain(HINSTANCE hInstance, DWORD dwReason) noexcept
DLLメイン関数実行通知関数 
LIB_COMMON_API bool CompareCharCode(wchar_t ch1, wchar_t ch2, bool bIgnore) noexcept
文字コード比較関数 
LIB_COMMON_API int ShowMessage(wchar_t const *pszMessage, HWND hWnd=nullptr, UINT uType=(MB_OK|MB_ICONEXCLAMATION)) noexcept
メッセージ表示関数 
LIB_COMMON_API void UtilNotifyConstructor(wchar_t const *pszFuncName) noexcept
コンストラクタ実行通知関数 
EWindowPosition
ウィンドウ表示位置種別列挙体 
LIB_COMMON_API bool ExpandFormatArgs(wchar_t *pszBuffer, size_t uSize, wchar_t const *pszFormat, va_list vaArgs) noexcept
書式設定文字列展開関数 
LIB_COMMON_API void UtilNotifyDestructor(wchar_t const *pszFuncName) noexcept
デストラクタ実行通知関数 
LIB_COMMON_API wchar_t const * GetDirPath(wchar_t *pszBuffer, size_t uSize, wchar_t const *pszPath) noexcept
ディレクトリパス取得関数 
LIB_COMMON_API wchar_t const * GetModuleName(HINSTANCE hInstance, wchar_t *pszBuffer=nullptr, size_t uSize=0) noexcept
モジュール名取得関数 
LIB_COMMON_API void UtilNotifyFatalError(wchar_t const *pszFileName, wchar_t const *pszFuncName, UINT uLineNumber) noexcept
致命的エラー発生通知関数 
LIB_COMMON_API void OutputDebugFormat(wchar_t const *pszFormat,...) noexcept
デバッグ出力関数 
LIB_COMMON_API wchar_t const * GetExeFileName(wchar_t *pszBuffer, size_t uSize) noexcept
実行ファイル名取得関数 
LIB_COMMON_API wchar_t const * GetExeFilePath(wchar_t *pszBuffer, size_t uSize) noexcept
実行ファイルパス取得関数 
LIB_COMMON_API wchar_t const * GetExeFileDir(wchar_t *pszBuffer, size_t uSize) noexcept
実行ファイルディレクトリパス取得関数 
LIB_COMMON_API DWORD SearchProcess(wchar_t const *pszPath)
プロセス検索関数 
LIB_COMMON_API bool SetWindowPosition(HWND hWnd, EWindowPosition ePos) noexcept
ウィンドウ表示位置設定関数 
LIB_COMMON_API wchar_t const * GetFileName(wchar_t *pszBuffer, size_t uSize, wchar_t const *pszPath) noexcept
ファイル名取得関数