00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 Open Download Manager Copyright (c) 2008 OpenDownloadManager.ORG 00004 */ 00005 00006 #include "stdafx.h" 00007 #include "vmsSingleInstance.h" 00008 00009 #ifdef _DEBUG 00010 #undef THIS_FILE 00011 static char THIS_FILE[]=__FILE__; 00012 #define new DEBUG_NEW 00013 #endif 00014 00015 vmsSingleInstance::vmsSingleInstance(LPCSTR pszAppName) 00016 { 00017 00018 m_hmx = CreateMutex (NULL, FALSE, pszAppName); 00019 00020 if (GetLastError () == ERROR_ALREADY_EXISTS) 00021 { 00022 00023 00024 CloseHandle (m_hmx); 00025 m_hmx = NULL; 00026 } 00027 } 00028 00029 vmsSingleInstance::~vmsSingleInstance() 00030 { 00031 00032 } 00033 00034 BOOL vmsSingleInstance::is_1stInstance() 00035 { 00036 return m_hmx != NULL; 00037 } 00038 00039 void vmsSingleInstance::set_1stInstanceHWND(HWND hwnd) 00040 { 00041 00042 } 00043 00044 HWND vmsSingleInstance::get_1stInstanceHWND() 00045 { 00046 return NULL; 00047 } 00048 00049 void vmsSingleInstance::Shutdown1stInstance() 00050 { 00051 PostMessage (get_1stInstanceHWND (), WM_APP_NEEDSHUTDOWN, 0, 0); 00052 } 00053 00054 void vmsSingleInstance::FreeInstance() 00055 { 00056 if (m_hmx) { 00057 CloseHandle (m_hmx); 00058 m_hmx = NULL; 00059 } 00060 }
1.5.6