445 |
|
|
446 |
public static string GetTSClientName(uint sessionID, IntPtr server) |
public static string GetTSClientName(uint sessionID, IntPtr server) |
447 |
{ |
{ |
|
System.IntPtr ppBuffer = System.IntPtr.Zero; |
|
|
int adrBuffer; |
|
|
uint pBytesReturned = 0; |
|
448 |
string clientName = ""; |
string clientName = ""; |
449 |
|
if (!System.Windows.Forms.SystemInformation.TerminalServerSession) |
450 |
|
{ |
451 |
|
System.IntPtr ppBuffer = System.IntPtr.Zero; |
452 |
|
int adrBuffer; |
453 |
|
uint pBytesReturned = 0; |
454 |
|
if (WTSQuerySessionInformation( |
455 |
|
server, |
456 |
|
sessionID, |
457 |
|
WTSInfoClass.WTSClientName, |
458 |
|
out ppBuffer, |
459 |
|
out pBytesReturned)) |
460 |
|
{ |
461 |
|
adrBuffer = (int)ppBuffer; |
462 |
|
clientName = Marshal.PtrToStringAnsi((System.IntPtr)adrBuffer); |
463 |
|
} |
464 |
|
|
465 |
if (WTSQuerySessionInformation( |
WTSFreeMemory(ppBuffer); |
466 |
server, |
} |
467 |
sessionID, |
else |
|
WTSInfoClass.WTSClientName, |
|
|
out ppBuffer, |
|
|
out pBytesReturned)) |
|
468 |
{ |
{ |
469 |
adrBuffer = (int)ppBuffer; |
clientName = System.Environment.MachineName; |
|
clientName = Marshal.PtrToStringAnsi((System.IntPtr)adrBuffer); |
|
470 |
} |
} |
|
|
|
|
WTSFreeMemory(ppBuffer); |
|
|
|
|
471 |
return clientName; |
return clientName; |
472 |
} |
} |
473 |
|
|