用VB,VC API函数更改计算名称的方法

解决方案 »

  1.   

    先占沙发。Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
    Private Sub Command1_Click()
    Dim myName
    myName = setcomputer(Text1.Text)
    MsgBox "修改成功!"
    End Sub
      

  2.   

    Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long 
    说明 
    设置新的计算机名 
    返回值 
    Long,非零表示成功,零表示失败。会设置GetLastError 
    参数表 
    参数 类型及说明 
    lpComputerName String,新的计算机名称。最多可有MAX_COMPUTERNAME_LENGTH个字符 
      

  3.   

    Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
    Private Sub Form_Load()
        'KPD-Team 1999
        'E-Mail: [email protected]
        Dim sNewName As String
        'Ask for a new computer name
        sNewName = InputBox("Please enter a new computer name.")
        'Set the new computer name
        SetComputerName sNewName
        MsgBox "Computername set to " + sNewName
    End Sub
      

  4.   

    就SetComputerName了。hoho 我是来蹭分地