A1VBCode Forums

vb my application run even in logoff state


http://www.a1vbcode.com/vbforums/Topic12311.aspx

By M.L.Srinivas - 6/22/2005

Hi,

I want vb my application run even in logoff state. For this I tried using windows task scheduler.

This went off successfully, but when I login I observed that the application is running as a process with no
UI.

Now, if the user tries to execute the application, I want to check whether my application is still running
in the background or not. If it is running in the background I want to make the same instance visible to the user.

How to do this?

I thought of reading the list of processes running and if the appl. is there I want to make it visible.

Is this possible?

Can we get the list of process running on the system from vb?


please help.


thanks
-Srinivas

By mayurkotlikar - 6/23/2005

You can also do this, i have added this to your DevX post:

I think instead of enumerating the processes, you go for creating a Mutex.
Public Declare Function CreateMutex Lib "kernel32.dll" Alias "CreateMutexA" ( _
lpMutexAttributes As Any, _
ByVal bInitialOwner As Boolean, _
ByVal lpName As String) As Long

Give your application name in lpName and preserve the handle returned.


Whenever your application starts, try to create the mutex, it the mutex already existes, it means you application is already running. Use FindWindows to find your application windows and show it.

Use CloseHandle to close the mutex handle when you exit.



I know we have App.PrevInstance but it is not reliable.