[02/03] How to set application run at once?
Hello expert.. hope you could help me with my problem...
I need a code that would make my application run only once..
once my application is running is shouldn't be open again..
and also.. when other application is open together with my application
and then user try to open my application again.. it should focus on my application without opening a new one..
thanks... hope you could help me..:)
Re: [02/03] How to set application run at once?
Project-->Properties-->Application-->Make single instance application
Re: [02/03] How to set application run at once?
thanks.. but there's not option for "Make single instance application" in application properties:) :)
Re: [02/03] How to set application run at once?
That option is available in .NET 2005/2008. Have a search on this forum. I am sure this has been discussed in past.
Re: [02/03] How to set application run at once?
Re: [02/03] How to set application run at once?
I have already check that thread but still doesn't help me due to im working with vb .net 2003... dey have discussed more on 2005 or higher version... thats why i couldnt relate.. pls guys.. help me.. thanks thanks!:cry: :cry:
Re: [02/03] How to set application run at once?
download vb2008 express. its free.
Re: [02/03] How to set application run at once?
Have u tried the code written in first two posts? It's for .NET 2002/2003.
Re: [02/03] How to set application run at once?
Yes.. but the problem is my application doesn't focus if there are other application opened..
Re: [02/03] How to set application run at once?
try like the below code
Code:
Dim procs As Process() = Process.GetProcesses()
For Each proc As Process In procs
If proc.MainWindowHandle <> IntPtr.Zero Then
SetForegroundWindow(proc.MainWindowHandle)
Application.Exit()
Exit Sub
End If
Next proc
Re: [02/03] How to set application run at once?
It has an error on proc.MainWindowHandle <> IntPtr.Zero...
i think MainWindowHandle is not a member of the Process class
Re: [02/03] How to set application run at once?
use proc.MainWindowTitle and assigned with your application title
for example proc.MainWindowTitle = "Windows Application1"
Re: [02/03] How to set application run at once?
proc.MainWindowTitle is a read only property
Re: [02/03] How to set application run at once?
Code:
If proc.MainWindowTitle = "Windows Application1" Then
.....
end if
Re: [02/03] How to set application run at once?