[B]Question asked by visitor Ramkumar[/b]
I want to open only one instance of an application (.exe) in my Machine, what should i do?
Printable View
[B]Question asked by visitor Ramkumar[/b]
I want to open only one instance of an application (.exe) in my Machine, what should i do?
In the main function of you application write the below code:-
public sub main()
dim pinstance as process = _ win32helper.getrunninginstance(process.getcurrentprocess().processname)
if not pinstance is nothing then
dim handle as intptr = pinstance.mainwindowhandle
else
'create new instance
end if
end sub
public shared function getrunninginstance(byval _ processname as string) as process
dim proclist() as process = _ process.getprocessesbyname(processname)
'if it is already running u will be returned with two processes
for each p as process in proclist
if p.id <> process.getcurrentprocess().id then
return p
end if
next
return nothing
end function
i think there is a option provided my MS to restrict running the multiple instances of same application
probably u can find it in projects property...