2 * @file main-win-utils.cpp
3 * @brief Windows版固有実装(ユーティリティー)
6 #include "main-win/main-win-utils.h"
7 #include "cmd-io/cmd-process-screen.h"
8 #include "locale/language-switcher.h"
9 #include "main-win/main-win-define.h"
10 #include "system/angband-version.h"
13 * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
15 * 特定の名前のミューテックスオブジェクトの所有権取得を試みる。
16 * 取得できない場合は他に変愚蛮怒のプロセスが起動しているとみなす。
17 * 取得したミューテックスのハンドルは明示的な解放は行わず、プロセス終了時にOSが解放する。
18 * @retval true 他に変愚蛮怒のプロセスが起動している
19 * @retval false 他に変愚蛮怒のプロセスは起動していない
21 bool is_already_running(void)
23 [[maybe_unused]] HANDLE hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
24 if (GetLastError() == ERROR_ALREADY_EXISTS) {
32 * @brief (Windows固有)画面をHTMLファイルに保存する
34 * ファイル保存ダイアログを表示し、指定のファイルに画面内容を保存する。
35 * @param hWnd ダイアログの親にするウインドウのハンドル
37 void save_screen_as_html(HWND hWnd)
39 std::vector<WCHAR> buf(MAIN_WIN_MAX_PATH + 1);
42 memset(&ofnw, 0, sizeof(ofnw));
43 ofnw.lStructSize = sizeof(ofnw);
44 ofnw.hwndOwner = hWnd;
45 ofnw.lpstrFilter = L"HTML Files (*.html)\0*.html\0";
46 ofnw.nFilterIndex = 1;
47 ofnw.lpstrFile = &buf[0];
48 ofnw.nMaxFile = MAIN_WIN_MAX_PATH;
49 ofnw.lpstrDefExt = L"html";
50 ofnw.lpstrInitialDir = NULL;
51 ofnw.lpstrTitle = _(L"HTMLでスクリーンダンプを保存", L"Save screen dump as HTML.");
52 ofnw.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
54 if (GetSaveFileNameW(&ofnw)) {
55 do_cmd_save_screen_html_aux(to_multibyte(&buf[0]).c_str(), 0);
60 * @brief 対象ファイルを選択した状態でエクスプローラーを開く
61 * @param filename 対象ファイル
63 void open_dir_in_explorer(char *filename) {
64 std::string str = "/select," + std::string(filename);
65 ShellExecuteW(NULL, NULL, L"explorer.exe", to_wchar(str.c_str()).wc_str(), NULL, SW_SHOWNORMAL);