OVH Cloud OVH Cloud

Identifier une exécution en contexte TSE

5 réponses
Avatar
smrhp
Bonsoir,

Je souhaite pouvoir identifier pour un programme écrit en WD55 s'il
s'exécute au cours d'une session Terminal Server "vraie" (donc sur une
session locale du serveur). Quelqu'un sait-t'il comment faire ça de
façon fiable (genre via une API ou je ne sais quoi d'autres )


Et pouvoir extraire le nom de l'utilisateur connecté ?

Merci

5 réponses

Avatar
B. Neve
Voici qui devrait t'intéresser...
Si tu sais en faire quelquechose, je suis intéressé également...

Je pense que l'API WTSEnumerateSessions de la DLL WTSAPI.DLL devrait faire
l'affaire.
En effet, voici ce que Bill est dit :
You can use the WTSEnumerateSessions function to retrieve the session ID,
computer name, and session state

Et plus précisément...

http://support.microsoft.com/kb/291789/en-us

Benoit

"smrhp" a écrit dans le message de news:

Bonsoir,

Je souhaite pouvoir identifier pour un programme écrit en WD55 s'il
s'exécute au cours d'une session Terminal Server "vraie" (donc sur une
session locale du serveur). Quelqu'un sait-t'il comment faire ça de
façon fiable (genre via une API ou je ne sais quoi d'autres )


Et pouvoir extraire le nom de l'utilisateur connecté ?

Merci




Avatar
B. Neve
Et encore ceci...
Detecting the Terminal Services Environment
To optimize performance, it is good practice for applications to detect
whether they are running in a Terminal Services client session. For example,
when an application is running on a remote session, it should eliminate
unnecessary graphic effects, as described in Graphic Effects. If the user is
running the application in a console session (directly on the terminal), it
is not necessary for the application to optimize its behavior.
The following code sample shows a function that returns TRUE if the
application is running in a remote session and FALSE if the application is
running on the console. It does not work on Windows NT 4.0 or earlier
releases of Windows NT.
BOOL IsRemoteSession(void)
{
return GetSystemMetrics( SM_REMOTESESSION );
}


Ou encore :
Et je pense le mieux....

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/termserv/wtsquerysessioninformation.asp

Voilà...

Benoit

"smrhp" a écrit dans le message de news:

Bonsoir,

Je souhaite pouvoir identifier pour un programme écrit en WD55 s'il
s'exécute au cours d'une session Terminal Server "vraie" (donc sur une
session locale du serveur). Quelqu'un sait-t'il comment faire ça de
façon fiable (genre via une API ou je ne sais quoi d'autres )


Et pouvoir extraire le nom de l'utilisateur connecté ?

Merci




Avatar
smrhp
B. Neve a pensé très fort :
Et encore ceci...
Detecting the Terminal Services Environment
To optimize performance, it is good practice for applications to detect
whether they are running in a Terminal Services client session. For example,
when an application is running on a remote session, it should eliminate
unnecessary graphic effects, as described in Graphic Effects. If the user is
running the application in a console session (directly on the terminal), it
is not necessary for the application to optimize its behavior.
The following code sample shows a function that returns TRUE if the
application is running in a remote session and FALSE if the application is
running on the console. It does not work on Windows NT 4.0 or earlier
releases of Windows NT.
BOOL IsRemoteSession(void)
{
return GetSystemMetrics( SM_REMOTESESSION );
}


Ou encore :
Et je pense le mieux....

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/termserv/wtsquerysessioninformation.asp




merci ces pistes semblent en effet très intéressantes... De mon côté
j'avais trouvé dans la base de registre des entrées dans HKCUVolatile
environement qui semblent contenir suffisement d'infos pour répondre à
mon problème, mais je vais explorer les pistes que tu donnes. Pas cette
semaine car en déplacement, mais si j'y parviens j'allimenterais ce fil
avec mes tentatives ;)
Avatar
Daniel
Bonjour,

smrhp writes:

B. Neve a pensé très fort :
> Et encore ceci... Detecting the Terminal Services Environment To
>optimize performance, it is good practice for applications to detect
>whether they are running in a Terminal Services client session. For
>example, when an application is running on a remote session, it
>should eliminate unnecessary graphic effects, as described in Graphic
>Effects. If the user is running the application in a console session
>(directly on the terminal), it is not necessary for the application
>to optimize its behavior. The following code sample shows a function
>that returns TRUE if the application is running in a remote session
>and FALSE if the application is running on the console. It does not
>work on Windows NT 4.0 or earlier releases of Windows NT. BOOL
>IsRemoteSession(void) { return GetSystemMetrics( SM_REMOTESESSION );
>}
>
>
> Ou encore : Et je pense le mieux....
>
>
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/terms erv/termserv/wtsquerysessioninformation.asp
>

merci ces pistes semblent en effet très intéressantes... De mon côt é
j'avais trouvé dans la base de registre des entrées dans HKCUVolatile
environement qui semblent contenir suffisement d'infos pour répondre à
mon problème, mais je vais explorer les pistes que tu donnes. Pas
cette semaine car en déplacement, mais si j'y parviens j'allimenterais
ce fil avec mes tentatives ;)





si c'est uniquement pour savoir si ton application est lancée en mode
TSE/RDP ou pas je fais le code suivant

// test si TSE ou pas
Xl_sEnvironnment est chaine = ""

Xl_sEnvironnement = SysEnvironnement("clientname")
Xl_sEnvironnement = ExtraitChaîne(Xl_sEnvironnement, 2, "=")
SI Xl_sEnvironnement<>EOT ALORS
XP_RDP=1 // variable projet qui permet de changer le comportement
XP_RDP_user=ExtraitChaîne(SysEnvironnement("SESSIONNAME"), 2, "=")
FIN


--
suivre ce lien pour répondre:
http://cerbermail.com/?2KrV3YZXnn
Daniel
;-)
Avatar
smrhp
Il se trouve que B. Neve a formulé :
Et encore ceci...
Detecting the Terminal Services Environment
To optimize performance, it is good practice for applications to detect
whether they are running in a Terminal Services client session. For example,
when an application is running on a remote session, it should eliminate
unnecessary graphic effects, as described in Graphic Effects. If the user is
running the application in a console session (directly on the terminal), it
is not necessary for the application to optimize its behavior.
The following code sample shows a function that returns TRUE if the
application is running in a remote session and FALSE if the application is
running on the console. It does not work on Windows NT 4.0 or earlier
releases of Windows NT.
BOOL IsRemoteSession(void)
{
return GetSystemMetrics( SM_REMOTESESSION );
}




celui-ci fonctionne très bien :
appeldll32("user32","GetSystemMetrics",0x1000)

retourne bien 1 lorsqu'on est en contrôle à distance. C'est à dire que
si une session est exécutée depuis un poste distant on a 1, si par
contre la session est exécutée directement sur la console serveur, elle
renvoit 0 (et renvoit 0 bien sûr sur un XP "poste de travail").