0
votes

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?

2
Can you provide an example of an existing application with this behaviour?Paul-Jan
There is no such thing as the "desktop tray" (blogs.msdn.com/b/oldnewthing/archive/2003/09/10/54831.aspx). Either you mean the taskbar (the place where opened windows are normally shown), or you mean the notification area /of the taskbar/, next to the clock. Please clarify.Andreas Rejbrand
My guess: The application should put a tray notification icon in every remote session available but none in the console session.ChristianWimmer

2 Answers

1
votes

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

0
votes

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.