There are three different methot to get computer name.
1. OS-GETENV Function :
MESSAGE
OS-GETENV("COMPUTERNAME") SKIP
OS-GETENV("HOSTNAME") SKIP
VIEW-AS ALERT-BOX INFO BUTTONS OK.
2. Use hostname utility : (windows only)
3. Using .NET assemblies ( Also available get Local IP adress ):
DEFINE VARIABLE oIPHostEntry AS System.Net.IPHostEntry NO-UNDO.
DEFINE VARIABLE oIPAddress AS System.Net.IPAddress NO-UNDO.
DEFINE VARIABLE cIPAddresses AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO INITIAL 1.
oIPHostEntry = System.Net.Dns:GetHostEntry(System.Net.Dns:GetHostName()).
DO WHILE TRUE:
oIPAddress = CAST(oIPHostEntry:AddressList:GetValue(iCount),"System.Net.IPAddress") NO-ERROR.
IF ERROR-STATUS:NUM-MESSAGES GT 0 THEN
LEAVE.
cIPAddresses = cIPAddresses + (IF (cIPAddresses GT "") EQ TRUE THEN CHR(10) ELSE "") + oIPAddress:ToString().
iCount = iCount + 1.
END.
MESSAGE "Host name: " System.Net.Dns:GetHostName() SKIP
"Ip Address: " cIPAddresses
VIEW-AS ALERT-BOX INFO BUTTONS OK.
For more info, to see Progress KB
1. OS-GETENV Function :
MESSAGE
OS-GETENV("COMPUTERNAME") SKIP
OS-GETENV("HOSTNAME") SKIP
VIEW-AS ALERT-BOX INFO BUTTONS OK.
2. Use hostname utility : (windows only)
DEFINE VARIABLE cHost AS CHARACTER NO-UNDO.
INPUT THROUGH hostname NO-ECHO.
SET cHost.
INPUT CLOSE.
DISPLAY cHost. 3. Using .NET assemblies ( Also available get Local IP adress ):
DEFINE VARIABLE oIPHostEntry AS System.Net.IPHostEntry NO-UNDO.
DEFINE VARIABLE oIPAddress AS System.Net.IPAddress NO-UNDO.
DEFINE VARIABLE cIPAddresses AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO INITIAL 1.
oIPHostEntry = System.Net.Dns:GetHostEntry(System.Net.Dns:GetHostName()).
DO WHILE TRUE:
oIPAddress = CAST(oIPHostEntry:AddressList:GetValue(iCount),"System.Net.IPAddress") NO-ERROR.
IF ERROR-STATUS:NUM-MESSAGES GT 0 THEN
LEAVE.
cIPAddresses = cIPAddresses + (IF (cIPAddresses GT "") EQ TRUE THEN CHR(10) ELSE "") + oIPAddress:ToString().
iCount = iCount + 1.
END.
MESSAGE "Host name: " System.Net.Dns:GetHostName() SKIP
"Ip Address: " cIPAddresses
VIEW-AS ALERT-BOX INFO BUTTONS OK.
For more info, to see Progress KB
Yorumlar
Yorum Gönder