zoukankan      html  css  js  c++  java
  • 获取计算机名


    ' 声明GetComputerName
    Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    ' 声明SetComputerName
    Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
    '定义一个获取计算机名字的函数
    Private Function GetCName(ByRef CName) As Boolean
        Dim sCName As String ' 计算机的名字
        Dim lComputerNameLen As Long ' 计算机名字的长度
        Dim lResult As Long ' GetComputerName的返回值
        Dim RV As Boolean ' GetCName返回值,若为TRUE则表示操作成功
        lComputerNameLen = 256
        sCName = Space(lComputerNameLen)
        lResult = GetComputerName(sCName, lComputerNameLen)
        If lResult <> 0 Then
            CName = Left$(sCName, lComputerNameLen)
            RV = True
        Else
            RV = False
        End If
        GetCName = RV
    End Function
    ' 定义一个修改计算机名字的函数
    Private Function SetCName(ByVal CName As String) As Boolean
        Dim lResult As Long
        Dim RV As Boolean
        lResult = SetComputerName(CName)
        If lResult <> 0 Then
            RV = True ' 修改成功
        Else
            RV = False
        End If
        SetCName = RV
    End Function

  • 相关阅读:
    SQL整理5
    SQL整理1 数据类型
    SQL整理2
    JavaScript 的DOM操作
    JavaScript 数据类型
    JavaScript
    CSS样式表
    sqlserver数据库 提纲
    Python基础第十二天:二分法算法
    Python基础第十一天:递归函数
  • 原文地址:https://www.cnblogs.com/lbnnbs/p/4784919.html
Copyright © 2011-2022 走看看