-
Notifications
You must be signed in to change notification settings - Fork 28
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
changbw001
committed
Jan 3, 2017
1 parent
5597733
commit cc03297
Showing
6 changed files
with
60 additions
and
14 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
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
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
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,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace DesktopNote | ||
{ | ||
class SingleInstance | ||
{ | ||
public static readonly IntPtr HWND_BROADCAST = (IntPtr)0xffff; | ||
public static readonly int RegisteredMsg = RegisterWindowMessage("WM_SHOW_DESKTOPNOTE"); | ||
//[DllImport("user32")] //not working when ShowInTaskbar set to false. | ||
//public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam); | ||
[DllImport("user32.dll", CharSet = CharSet.Auto)] | ||
public static extern bool SendNotifyMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam); | ||
[DllImport("user32.dll")] | ||
public static extern int RegisterWindowMessage(string message); | ||
|
||
public enum MutexScope { Local, Global } | ||
|
||
/// <summary> | ||
/// Return created mutex if the mutex name does not exist. Returns null if the mutex name exists. | ||
/// </summary> | ||
public static bool CheckExist(string uniquestr, MutexScope scope = MutexScope.Global) | ||
{sdrsfsdf | ||
bool createdNew; | ||
new Mutex(true, scope.ToString() + @"\" + uniquestr, out createdNew); | ||
return !createdNew; | ||
} | ||
} | ||
} |