unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jwaWTSAPI32, jwaWinBase;
type
TForm1 =
class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
nProcessID, nSessionID, nByteCount : DWORD;
acNameBuff : Pointer;
begin
nProcessID := GetCurrentProcessId;
if ProcessIdToSessionID( nProcessID, nSessionID)
then begin
if nSessionID > 0
then begin
if WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, nSessionId, WTSClientName, acNameBuff, nByteCount)
then begin
Edit1.Text := StrPas(PChar(acNameBuff));
// in sName steht jetzt der Rechnername drin
WTSFreeMemory(acNameBuff);
end;
end;
end;
end;
end.