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

  • 相关阅读:
    css基础--Display(显示) and Visibility(可见性)and position (定位)
    css3基础--Margin(外边距)&&padding(外边距)
    前端求职-js
    前端求职-html&css
    css基础3--box module&Border
    css基础-font&link&list属性
    值得学习的PHP
    c++构造函数浅析
    变量定义原则
    函数
  • 原文地址:https://www.cnblogs.com/lbnnbs/p/4784919.html
Copyright © 2011-2022 走看看