That did it. Thanks for the help everyone.
"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:etM7ayPTGHA.5828@TK2MSFTNGP14.phx.gbl...[color=blue]
> Marco,
>
> After long discussions probably the best.
>
> Have a look for it on our website.
>
>
http://www.vb-tips.com/default.aspx?...6-343ac05a7617
>
> I hope this helps,
>
> Cor
>
> "Marco" <nospampleasesyxxpk@hotmail.com> schreef in bericht
> news:uNwZx8OTGHA.2088@TK2MSFTNGP14.phx.gbl...[color=green]
>>I should mention that this is for VB2003.
>>
>> I need to make sure that only one instance of my application is running
>> at a time. I already have some code that does this and it does work but
>> I ran into a problem. Here is the code. It returns true if the
>> application is already running.
>>
>> If
>> UBound(Diagnostics.Process.GetProcessesByName(Diag nostics.Process.GetCurrentProcess.ProcessName))[color=darkred]
>> > 0 Then[/color]
>> Return True
>> Else
>> Return False
>> End If
>>
>> The code is simple and it works great ... at least until you have more
>> then one user logged in at once. This was never an issue until now.
>> What's happening is that the software has been installed in a public
>> computer where a few people will be using it per day. Instead of logging
>> on and off all the time they were told to stay logged in and use the
>> windows key + L to go back to the login screen when they are done. In
>> this scenario you will have 2 different users opening up the same
>> software in the same computer under different user accounts. The problem
>> with the code is that it checks all of the processes for the same name
>> instead of the just the ones that belong to the logged in user. I've
>> tried to get it to check by user only but could not find a solution. Is
>> it possible to do that or do I have to use a new way to check if the
>> application is already running? If so can someone point me in the right
>> direction? Thanks.
>>[/color]
>
>[/color]