473,382 Members | 1,359 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,382 software developers and data experts.

Only Allow One Instance Of EXE When Shell

I have a VB6 program that is going to Shell a VB.Net program to run. I want
the VB.Net program to only run once, so it if is not running and it is
Shelled, the program runs; if it is already running and it is Shelled, then
I wish the program to become visible. I do have to use the Shell process
since I do not have control over the VB6 program, other than what parameters
are sent to the Shell. Any ideas on how this can be accomplished?

Thank You,
Derek
Jul 19 '05 #1
2 4902
Hello,

"Derek Hart" <dm****@gte.net> schrieb:
I have a VB6 program that is going to Shell a VB.Net
program to run. I want the VB.Net program to only run
once, so it if is not running and it is Shelled, the program
runs; if it is already running and it is Shelled, then I
wish the program to become visible. I do have to
use the Shell process since I do not have control over the
VB6 program, other than what parameters are sent to the
Shell. Any ideas on how this can be accomplished?


In the VB.NET application:

\\\
Imports System.Threading
..
..
..
Dim m As Mutex = _
New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")
If m.WaitOne(10, False) Then
Application.Run(New Form1())
m.ReleaseMutex()
Else
MessageBox.Show("Application already running!")
End If
///

You can use 'AppActivate' to activate the other instance.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Jul 19 '05 #2
Got this from a previous posting:

Just add that piece of code (here in C#) in your main method (you need to
include the System.Diagnostic namespace) :
Process currentProcess = Process.GetCurrentProcess();

Process [] allProcesses =
Process.GetProcessesByName(currentProcess.ProcessN ame);
if (allProcesses.Length > 1)

{

MessageBox.Show(currentProcess.ProcessName + " is already running !",
currentProcess.ProcessName, MessageBoxButtons.OK, MessageBoxIcon.Error);

}

else

{

//do your stuff here

}

"Derek Hart" <dm****@gte.net> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
I have a VB6 program that is going to Shell a VB.Net program to run. I want the VB.Net program to only run once, so it if is not running and it is
Shelled, the program runs; if it is already running and it is Shelled, then I wish the program to become visible. I do have to use the Shell process
since I do not have control over the VB6 program, other than what parameters are sent to the Shell. Any ideas on how this can be accomplished?

Thank You,
Derek

Jul 19 '05 #3

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

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
5
by: hikums | last post by:
How are multiple instances monitored? For example, there are 30 instances running on a AIX BOX running DB2 V8, is ps -ef |grep "inst" the best way to see if the instance is running, where instanes...
4
by: Andrew Chanter | last post by:
I have a VB app that has a routine that runs macros in a (password protected) Access 97 db. (I have attached the code below.) Most of these macros end up opening a form in the Access db for the...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
3
by: Derek Hart | last post by:
I have a VB6 program that is going to Shell a VB.Net program to run. I want the VB.Net program to only run once, so it if is not running and it is Shelled, the program runs; if it is already...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
0
by: midlothian | last post by:
I have some long Excel routines that I would like to run from my database in a hidden, second instance of the same Access db. The macro I pass to the shell command to open the second instance...
11
by: Hari Sekhon | last post by:
I have written a script and I would like to ensure that the script is never run more than once at any given time. What is the best way of testing and exiting if there is another version of this...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.