Results 1 to 7 of 7

Thread: [RESOLVED] Check whether application is running for another user

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,373

    Resolved [RESOLVED] Check whether application is running for another user

    I have an application that establishes connections to several hardware devices. Sometimes users will leave the application open and abandon the PC. Eventually the lockout screen appears and a new user comes along and logs in and launches another instance of the application. However, attempts to establish connections to the hardware devices fail with the new instance as the connection established by the existing instance is blocking ports etc. The devices only allow one instance of the application to connect.

    Is there a way of detecting whether another instance of the application is active via another logged-on user?

    Perhaps the application could require a machine reboot if another instance were to be detected.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Check whether application is running for another user

    I'm not 100% sure but I think that Process.GetProcessesByName can get processes for all users if the current user is an admin. If they're not then they shouldn't be able to get info about other user's anyway. I think that it should be possible to detect the computer locking so could you not have the application clean up when that happens, so it will not monopolise resources if that session isn't active?

  3. #3
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    Re: Check whether application is running for another user

    Will this always run fro the same machine or are there several machines competing for the same set of devices?

    Why not just catch the exceptions when trying to connect the second (blocked) session?
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,373

    Re: Check whether application is running for another user

    Quote Originally Posted by jmcilhinney View Post
    I'm not 100% sure but I think that Process.GetProcessesByName can get processes for all users if the current user is an admin. If they're not then they shouldn't be able to get info about other user's anyway. I think that it should be possible to detect the computer locking so could you not have the application clean up when that happens, so it will not monopolise resources if that session isn't active?
    Users will generally be standard users. I don't require information about any other particular user per se but rather whether the PC is running another instance of the application via another user's account.

    Are you saying that it might be possible for the application to detect the PC locking and close itself down when this event is detected?

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,373

    Re: Check whether application is running for another user

    Quote Originally Posted by FunkyDexter View Post
    Will this always run fro the same machine or are there several machines competing for the same set of devices?
    There may be several machines accessing the one database but each machine will have its own set of hardware devices to connect to.

    Quote Originally Posted by FunkyDexter View Post
    Why not just catch the exceptions when trying to connect the second (blocked) session?
    I am trying to avoid this kind of inefficiency. I would prefer a solution which involves avoiding the exception in the first place. Also there could be other reasons for the same exception which may require some kind of support team intervention. Ideally I would like to detect whether another instance is running and suggest a reboot or (even better) close the application when a PC lock event is detected.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Check whether application is running for another user

    Quote Originally Posted by robertx View Post
    Are you saying that it might be possible for the application to detect the PC locking and close itself down when this event is detected?
    I just searched the web for "vb.net detect locking windows" and this was the first result:

    https://code.msdn.microsoft.com/wind...State-b6704e7a

    I haven't looked closely so I'm not sure but it seems like it might be useful.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,373

    Re: Check whether application is running for another user

    Quote Originally Posted by jmcilhinney View Post
    I just searched the web for "vb.net detect locking windows" and this was the first result:

    https://code.msdn.microsoft.com/wind...State-b6704e7a

    I haven't looked closely so I'm not sure but it seems like it might be useful.
    Whilst the sample application in this link is not coded in a thread-safe manner, it nevertheless demonstrates how to detect that the current Windows session has been locked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width