SetComputerNameEx() Return Codes?
- From: "Eric Dropps" <dropps@xxxxxxxxxxxxxxx>
- Date: Tue, 4 Sep 2007 15:46:27 -0400
Hello all,
Having a problem with SetComputerNameEx() -- the API says it returns 0 on failure, but for me it is always returning a random number on failure or success. Interestingly though, the code is working in terms of renaming a computer, assuming the new name is valid. How can i check to see if the name is invalid, since the function is always returning a non-zero value?
Sample Code Below:
Private Sub RenameComputer(ByVal strNewName)
Dim RtrnVal
RtrnVal = SetComputerNameEx(COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname, strNewName)
MsgBox(RtrnVal)
If RtrnVal = 0 Then
MsgBox("Error: Could not rename computer. Check to make sure the computer name does not contain spaces, symbols, or punctuation.")
myCaller.LblStatus.Text = "There was an error renaming the computer"
Else
myCaller.LblStatus.Text = "Computer renamed successfully. Please reboot to continue."
myCaller.JoinDomainButton.Enabled = False
myCaller.DeptsBox.Enabled = False
End If
End Sub
Eric Dropps
Jr. Systems Administrator
Harvard University FAS Computer Services
dropps@xxxxxxxxxxxxxxx 617.495.9768
.
- Follow-Ups:
- Re: SetComputerNameEx() Return Codes?
- From: Mattias Sjögren
- Re: SetComputerNameEx() Return Codes?
- Prev by Date: Re: how can I change this get code to post code
- Next by Date: Re: Array Comparisons in Program
- Previous by thread: Suppress PDF document popup on Fax client desktop
- Next by thread: Re: SetComputerNameEx() Return Codes?
- Index(es):