Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the client name
Message
De
19/04/2015 04:37:02
 
 
À
18/04/2015 12:56:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01618480
Message ID:
01618689
Vues:
35
>>>Hi All
>>>
>>>Running an app under terminal services / remote desktop and if I use the Windows Remote desktop Services Manager and look at a logged in user I can see various info about the user such as their log in name but also the "client name" which appears to be the name of the computer that the user is using. For an example see the screenshot attached. Does anyone know an API routine to get that info from within a VFP program?
>>
>>
>>Just as an FYI for anyone interested The solution is incredibly simply and does not require accessing any API. You can retrieve the users computer name under a terminal services session simply using Windows Scripting Host in 2 lines ("doh!"):
>>
>>
>>objShell = CreateObject("WScript.Shell")
>>strClient = objShell.ExpandEnvironmentStrings("%clientname%")
>>? strClient
>>
>>
>>NB: This will only return a valid client name if it is run under a terminal services session. Otherwise you get just "%clientname%".
>
>For your information, WSH is only a wrapper around the APIs. And it's also worth noting that many companies have a policy of blocking WSH, so it's a usually better solution to use the APIs directly..

OK, thanks. We are using this on our own terminal services servers

.
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform