任务单 #31234

二重起動防止パッチ

开放日期: 2013-04-27 22:05 最后更新: 2020-12-21 22:51

报告人:
属主:
类型:
状态:
关闭
组件:
(无)
优先:
5 - Medium
严重性:
5 - Medium
处理结果:
Fixed
文件:

Details

Windows用の二重起動防止パッチです。 同じ名前のミューテックスがあれば既に起動しているという判定です。

diff -urN hengband-trunk-rev3390-win\Hengband\src/main-win.c hengband-trunk-rev3390-win_prevent_multirun\Hengband\src/main-win.c
--- hengband-trunk-rev3390-win\Hengband\src/main-win.c	2013-04-27 21:37:56.558747400 +0900
+++ hengband-trunk-rev3390-win_prevent_multirun\Hengband\src/main-win.c	2013-04-27 22:00:05.666667300 +0900
@@ -5340,6 +5340,20 @@
 }
 
 
+bool is_already_running()
+{
+	bool result = FALSE;
+	HANDLE hMutex;
+
+	hMutex = CreateMutex(NULL, TRUE, VERSION_NAME);
+	if (GetLastError() == ERROR_ALREADY_EXISTS)
+	{
+		result = TRUE;
+	}
+	return result;
+}
+
+
 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
 		       LPSTR lpCmdLine, int nCmdShow)
 {
@@ -5355,6 +5369,19 @@
 	/* Save globally */
 	hInstance = hInst;
 
+	/* Prevent multiple run */
+	if (is_already_running())
+	{
+#ifdef JP
+		MessageBox(NULL, "変愚蛮怒はすでに起動しています。", 
+			"エラー!", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+#else
+		MessageBox(NULL, "Hengband is already running.",
+			"Error", MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
+#endif
+		return FALSE;
+	}
+
 	/* Initialize */
 	if (hPrevInst == NULL)
 	{

任务单历史 (3/4 Histories)

2013-04-27 22:05 Updated by: shimitei
  • New Ticket "二重起動防止パッチ" created
2013-04-28 00:01 Updated by: dis-
  • 属主 Update from (无) to dis-
2013-04-28 00:03 Updated by: dis-
  • Ticket Close date is changed to 2013-04-28 00:03
  • 状态 Update from 开启 to 关闭
评论

動作確認の上、パッチ適用しました。ありがとうございます。

2020-12-21 22:51 Updated by: deskull

Attachment File List

No attachments

编辑

Please login to add comment to this ticket » 登录名