473,225 Members | 958 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,225 software developers and data experts.

preventing second application instance starting

Hello. I have written a simple image viewer application using C# .NET.
It only needs to display one image at a time. When a different program, in
C, running on the same machine, does a
"system(myfile.a2d2)" call, it automatically starts my image viewer
application (using file type association). a2d2 is the image file
format, my own. If the C program does the system call again for a
different image, I find that it starts a new instance of my image
viewer application running. I would like to have it so that the
already-running instance senses that another image is to be loaded,
and loads it, rather than starting a whole second instance of the
application. Any help on this OS and application question would be
appreciated.

Jul 21 '05 #1
2 1974
Hi John, have a look at this . . . It's not C# but not that difficult to
convert . .(if you want the original text look for PrevInstance in MSDN)

PrevInstance Property Changes in Visual Basic .NET
See Also
App Object Changes in Visual Basic .NET

In Visual Basic 6.0, the PrevInstance property of the App object was used to
determine if a previous instance of an application was running. There is no
equivalent for this property in Visual Basic .NET; however, the following
code can be used to test for a previous instance:

' Visual Basic .NET
Function PrevInstance() As Boolean
If
Ubound(Diagnostics.Process.GetProcessesByName(Diag nostics.Process.GetCurrentProcess.ProcessName))
0 Then Return True
Else
Return False
End If
End FunctionNote The behavior is slightly different than that of Visual
Basic 6.0. In Visual Basic 6.0, PrevInstance returned true only if the full
path and file name were exactly the same; in Visual Basic .NET, this
function will return true for two instances started from different paths. In
addition, PrevInstance would never return true for the first instance of an
application; in Visual Basic .NET, once a second instance is loaded, the
first instance will also return true.

"johnmann56" <jo********@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com... Hello. I have written a simple image viewer application using C# .NET.
It only needs to display one image at a time. When a different program, in
C, running on the same machine, does a
"system(myfile.a2d2)" call, it automatically starts my image viewer
application (using file type association). a2d2 is the image file
format, my own. If the C program does the system call again for a
different image, I find that it starts a new instance of my image
viewer application running. I would like to have it so that the
already-running instance senses that another image is to be loaded,
and loads it, rather than starting a whole second instance of the
application. Any help on this OS and application question would be
appreciated.

Jul 21 '05 #2
Hello John. That is quite useful to know, the PrevInstance property and the
code you attached. That will come in useful certainly. Thank you very much.
John

"JohnFol" wrote:
Hi John, have a look at this . . . It's not C# but not that difficult to
convert . .(if you want the original text look for PrevInstance in MSDN)

PrevInstance Property Changes in Visual Basic .NET
See Also
App Object Changes in Visual Basic .NET

In Visual Basic 6.0, the PrevInstance property of the App object was used to
determine if a previous instance of an application was running. There is no
equivalent for this property in Visual Basic .NET; however, the following
code can be used to test for a previous instance:

' Visual Basic .NET
Function PrevInstance() As Boolean
If
Ubound(Diagnostics.Process.GetProcessesByName(Diag nostics.Process.GetCurrentProcess.ProcessName))
> 0 Then

Return True
Else
Return False
End If
End FunctionNote The behavior is slightly different than that of Visual
Basic 6.0. In Visual Basic 6.0, PrevInstance returned true only if the full
path and file name were exactly the same; in Visual Basic .NET, this
function will return true for two instances started from different paths. In
addition, PrevInstance would never return true for the first instance of an
application; in Visual Basic .NET, once a second instance is loaded, the
first instance will also return true.

"johnmann56" <jo********@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Hello. I have written a simple image viewer application using C# .NET.
It only needs to display one image at a time. When a different program, in
C, running on the same machine, does a
"system(myfile.a2d2)" call, it automatically starts my image viewer
application (using file type association). a2d2 is the image file
format, my own. If the C program does the system call again for a
different image, I find that it starts a new instance of my image
viewer application running. I would like to have it so that the
already-running instance senses that another image is to be loaded,
and loads it, rather than starting a whole second instance of the
application. Any help on this OS and application question would be
appreciated.


Jul 21 '05 #3

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

Similar topics

1
by: Jon Pope | last post by:
I've got an application that uses a Mutex to prevent multiple instances of the application from launching. This works great for me. However, what I would like to do is when a second attempt to...
7
by: Joe Ocampo | last post by:
Does anyone know how to prevent multiple applications from being instantiated?
2
by: johnmann56 | last post by:
Hello. I have written a simple image viewer application using C# .NET. It only needs to display one image at a time. When a different program, in C, running on the same machine, does a...
1
by: whitehorse | last post by:
When the warehousecontroller service is invoked, the following error message is sent to the application log: Event Type: Error Event Source: TFS Warehouse Event Category: None Event ID: 3000...
0
by: Massimiliano Campagnoli | last post by:
Can you explain me what is going on here ? J:\ is a network drive located on a samba server. DB2 is V7.2 fixpak 14. net use j: \\linuxserver\backupdb2 The command completed successfully. ...
22
by: Mark Rae | last post by:
Hi, I'm using the following example for this: http://www.yoda.arachsys.com/csharp/faq/#one.application.instance which works perfectly on Vista, but not on XP... Doesn't throw any errors,...
2
by: giddy | last post by:
hi, I've heard its possible!? Is it? : preventing an application from running over a network. Or it would even be great if i could know if someone from a networked computer tried to run my...
5
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based...
2
by: Cramer | last post by:
Is there some way - perhaps in Application_Start - that I can prevent an ASP.NET (3.5) application from starting. I would like to perform some environment validation and pipeline configuration...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.