forked from DiscordMessenger/dm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0465176
commit 989583f
Showing
6 changed files
with
71 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "InstanceMutex.hpp" | ||
|
||
void InstanceMutex::Close() | ||
{ | ||
if (m_handle) | ||
{ | ||
CloseHandle(m_handle); | ||
m_handle = NULL; | ||
} | ||
} | ||
|
||
HRESULT InstanceMutex::Init() | ||
{ | ||
#ifdef DISABLE_SINGLE_INSTANCE | ||
return 0; | ||
#else | ||
|
||
SetLastError(NO_ERROR); | ||
m_handle = CreateMutex(NULL, TRUE, L"DiscordMessenger"); | ||
|
||
const DWORD error = GetLastError(); | ||
if (error == ERROR_ALREADY_EXISTS) | ||
Close(); | ||
|
||
return error; | ||
#endif | ||
} | ||
|
||
InstanceMutex::~InstanceMutex() | ||
{ | ||
Close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <windows.h> | ||
|
||
class InstanceMutex | ||
{ | ||
private: | ||
HANDLE m_handle = NULL; | ||
|
||
void Close(); | ||
|
||
public: | ||
HRESULT Init(); | ||
~InstanceMutex(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,5 @@ enum eWmUserMsgs | |
WM_RECREATEMEMBERLIST, | ||
|
||
WM_UPDATETEXTSIZE = WM_APP, // used by the MessageEditor | ||
WM_RESTORE, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters