Click here to Skip to main content
15,041,548 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently working on a windows gadget(sidebar in windows 7), its not a windows application, but it is a sidebar like sticky notes. I am unable to limit the instances of the gadget. I just want one instance running at a time and no more.


Note: Gadgets are Windows SideBars that are similar to sticky notes or the calendar on the desktop.

What I have tried:

I have no clue what has to be done in order to achieve this.
Posted
Updated 5-Jul-17 1:48am
v3
Comments
OriginalGriff 5-Jul-17 5:17am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So explain what your gadget is (we don't even know if it's an application, a control, a class, or whatever), how it is "created" to produce multiple instances, what language we are talking about, and so on.
Use the "Improve question" widget to edit your question and provide better information.
Hrishikesh 5-Jul-17 7:13am
   
OriginalGriff As I have clearly stated that "windows gadget"( i.e. the sidebar) in windows is developed using HTML & Javascript. The only way you can access these gadgets is by right clicking on the desktop and then clicking on Gadgets(Windows 7). I hope now the picture is clear. I apologize for the confusion created. Kindly help me with same.

In C# you can use a Mutex:
C#
public static void Main()
	{
		bool createdNew;
		var mutex = new Mutex(false, "SingletonWinAppMutex", out createdNew);

		if (!createdNew)
		{
			MessageBox.Show(@"You can only start one gadget instance !");
			Application.Exit();
			return;
		}
...
   
v2
Comments
Hrishikesh 5-Jul-17 7:14am
   
@RickZeeland : I apologize for the confusion created in this context. I have a "windows gadget"( i.e. the sidebar) in windows is developed using HTML & Javascript. The only way you can access these gadgets is by right clicking on the desktop and then clicking on Gadgets(Windows 7). I hope now the picture is clear. I apologize for the confusion created. Kindly help me with same.
Javascript: maybe this live-mutex API will be of interest to you:
A better mutex for Node.js – Alex Mills – Medium[^]
It's a bit long winded but somewhere near the bottom of the article there's an example.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900