ERFORDERLICHE
OBJEKTE
1 Commandbutton (Command1)
1 Textbox (Text1)
FORM-CODE
Private Declare Function GetComputerName Lib "kernel32" _
Alias "GetComputerNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Private Declare Function SetComputerName Lib "kernel32" _
Alias "SetComputerNameA" (ByVal lpComputerName _
As String) As Long
Private Function Computername_ermitteln()
Dim s As String
s = Space$(255)
Call GetComputerName(s, Len(s))
Computername_ermitteln = s
End Function
Private Function Computername_setzen(PC_Name)
res = SetComputerName(PC_Name)
'res liefert:
'0, falls die Aktion nicht erfolgreich war,
'1, falls die Aktion erfolgreich war
Computername_setzen = res
End Function
Private Sub Command1_Click()
x = Computername_setzen(Text1.Text)
If x = 1 Then
MsgBox "Computername gesetzt !"
Else
MsgBox "Fehler !"
End If
End Sub
Private Sub Form_Load()
Text1.Text = Computername_ermitteln()
Command1.Caption = "Computername setzen"
End Sub
|