473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

one instance of the program?

how to ensure that my program can't start twice on the computer and tell
user something like "Program already started"
Can I do anything with Process Class
thx
Nov 21 '05 #1
6 840
You can use Process.GetProcessesByName(processName) to guess if there is
another instance running.

You can get the process name with
Syetm.Reflection.Assembly.GetExecutingAssembly.Get Name.Name.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Dzemo" <dz***@wizard.ba> escribió en el mensaje
news:%2****************@TK2MSFTNGP09.phx.gbl...
how to ensure that my program can't start twice on the computer and tell
user something like "Program already started"
Can I do anything with Process Class
thx

Nov 21 '05 #2
Dzemo,

See this page on our website, in my opinion the best implementation for
that.

http://www.windowsformsdatagridhelp....6-343ac05a7617

I hope this helps,

Cor
Nov 21 '05 #3
"Dzemo" <dz***@wizard.ba> schrieb:
how to ensure that my program can't start twice on the computer and tell
user something like "Program already started"


See:

<URL:http://www.yoda.arachsys.com/csharp/faq/#one.application.instance>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #4
Carlos,

"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAMsogecable.com> schrieb:
You can use Process.GetProcessesByName(processName) to guess if there is
another instance running.

You can get the process name with
Syetm.Reflection.Assembly.GetExecutingAssembly.Get Name.Name.


This basically works, but note that the process name is not necessarily
unique.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
Hi Cor,

Just curious, if the app crashes with an unhandled exception, is the mutex
released? Isn´t an exception handler needed?

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Cor Ligthert [MVP]" <no************@planet.nl> escribió en el mensaje
news:OF**************@TK2MSFTNGP10.phx.gbl...
Dzemo,

See this page on our website, in my opinion the best implementation for
that.

http://www.windowsformsdatagridhelp....6-343ac05a7617

I hope this helps,

Cor

Nov 21 '05 #6
Carlos,

I don't know however I could run this program as often as I did like.

\\\
Public Class myw
Public Shared Sub main()
MessageBox.Show("I am new alive")
Dim owned As Boolean
Dim mut As New System.Threading.Mutex _
(True, "xvcjsdf67AS124#$3", owned)
End
End Sub
End Class
////

I don't know a better method to kill a program

Cor
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Eugene | last post by:
I am trying to use db2batch from my XP client against a remote database. And here's what I am getting: C:\work\Tuning\DB2\db2batch> db2batch -d oakl0 -a fs/fs -f db2batch.sql Running in...
5
by: Aaron | last post by:
I created a simple exe program in c#. I would like to run one instance of the program at a time. if i click the exe after the program is already opened it should NOT start a new instance of the...
1
by: Kevin Otte | last post by:
Hi, I'm currently working on a program that is supposed to allow only one instance of itself. How can I transfer the data that is passed to a second instance as a parameter to the first...
18
by: Steve Barnett | last post by:
I want to ensure that there is only ever one instance of my app running on a single PC at any time. I understand that I can achieve this by using a mutex and, if I can't take ownership of the...
7
by: Jeffery Tyree | last post by:
I am writing an application in C#.NET that is "AlwaysOnTop" and there should only be one instance of this program running at any given time. The "AlwaysOnTop" piece is working just fine but I...
3
by: Mark Jerde | last post by:
VS 2005. When I google "CSharp single instance form" the returned pages usually use a Mutex or the VB.NET runtime library....
2
by: Mesan | last post by:
Hello everyone, Thanks to many useful posts in this newsgroup and others, I've been able to come very close to something I've been wanting to do for a very long time. I've figured out how to...
13
by: JohnQ | last post by:
Why would anyone write: class SomeThing // class littered with non-domain single-instancing code :( { private: SomeThing(); static SomeThing* pInstance_; public: static SomeThing*...
3
by: Jon | last post by:
My main form opens up another form, and from this other form, I'd like to access things in the main form. The problem is that although I know the name of the class of the main form (FormMain) I...
8
by: akineko | last post by:
Hello everyone, This may not be a Python specific challenge. I have a GUI program written in Python + Tkinter. It works very well. Now, I would like to start it from a shell script. As my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.