views:

150

answers:

2

HI,

Im using Delphi and I want to make an application that can do the following

When started from within Terminal services (remote desktop), if another user logs into another terminal services session they should be able to see the application running in the desktop tray. However if a user sitting at the server logs in then they shouldn't see the application running in the desktop tray. Its fine if everyone can see it running in the process list, just not the desktop tray.

How can I do this?

A: 

Assumption: You are logging into a Windows Server - two people cannot RDP at the same time on the Desktop OSes. My experience with this is that you should not see applications running visually - ie on the desktop or on the taskbar or tray icon area.

If you go into the task manager and look at the processes running - you may see process running. Also, if you are Administrator, then you may "Kill" the process, else there is nothing you can do with it.

Does this help?

Please clarify what you are asking.

MDV2000
Hi, sorry yes I meant the taskbar tray area. Basically what I want to do is: A user logs into a session via remote desktop (terminal services) and starts an application that sits in the taskbar tray and then logs out. If another user logs in via remote desktop they should see the application running in the taskbar tray. However a user who is logged in locally at the server should not see it running.
no spoon
+1  A: 

Make your application launch on startup on every user, then use this function to determine whether to quit or not:

#include <windows.h>
#include <winternl.h>

BOOL IsRunningOnTerminalServerClient( void )
{
    PWINSTATIONQUERYINFORMATIONW WinStationQueryInformationW;
    WINSTATIONINFORMATIONW wsInfo;
    HINSTANCE hInstWinSta;
    ULONG ReturnLen;

    hInstWinSta = LoadLibraryA( "winsta.dll" );
    if( hInstWinSta )
    {
        WinStationQueryInformationW = (PWINSTATIONQUERYINFORMATIONW)
            GetProcAddress( hInstWinSta, "WinStationQueryInformationW" );
        if( WinStationQueryInformationW &&
                WinStationQueryInformationW( SERVERNAME_CURRENT, 
                    LOGONID_CURRENT, 
                    WinStationInformation,
                    &wsInfo, 
                    sizeof(wsInfo), 
                    &ReturnLen ) &&
                ( wsInfo.LogonId != 0 ) )
        {
            FreeLibrary( hInstWinSta );
            return( TRUE );
        }
        FreeLibrary( hInstWinSta );
    }
    return FALSE;
}

Pulled from http://msdn.microsoft.com/en-us/library/aa383827(v=VS.85).aspx

Paul Betts
Yep that looks like what I need, thanks for that.
no spoon