From 57cf5f7e26b171e680ba27958a414703a51768e4 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 14 Oct 2005 08:26:02 +0000 Subject: win32: prohibit duplicate exec using CreateMutex(). git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@648 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 4 ++++ src/main.c | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9a1644a1..612a05ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-10-14 + + * src/main.c: win32: prohibit duplicate exec using CreateMutex(). + 2005-10-14 * libsylph/procmime.c diff --git a/src/main.c b/src/main.c index 0b3582ca..79da0a7e 100644 --- a/src/main.c +++ b/src/main.c @@ -87,6 +87,10 @@ # include "ssl.h" #endif +#ifdef G_OS_WIN32 +# include +#endif + #include "version.h" gchar *prog_version; @@ -163,11 +167,11 @@ int main(int argc, char *argv[]) app_init(); parse_cmd_opt(argc, argv); -#ifdef G_OS_UNIX /* check and create unix domain socket for remote operation */ lock_socket = prohibit_duplicate_launch(); if (lock_socket < 0) return 0; +#ifdef G_OS_UNIX if (cmd.status || cmd.status_full) { puts("0 Sylpheed not running."); lock_socket_remove(); @@ -742,6 +746,21 @@ static gchar *get_socket_name(void) static gint prohibit_duplicate_launch(void) { +#ifdef G_OS_WIN32 + HANDLE hmutex; + + hmutex = CreateMutexA(NULL, FALSE, "Sylpheed"); + if (!hmutex) { + g_warning("cannot create Mutex\n"); + return -1; + } + if (GetLastError() == ERROR_ALREADY_EXISTS) { + debug_print(_("another Sylpheed is already running.\n")); + return -1; + } + + return 0; +#else gint uxsock; gchar *path; @@ -821,6 +840,7 @@ static gint prohibit_duplicate_launch(void) fd_close(uxsock); return -1; +#endif } static gint lock_socket_remove(void) -- cgit v1.2.3