⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getcomputername_unicode.bas

📁 个人VB学习源码精选,自己学习时的一些编程小程序,希望对大家有帮助
💻 BAS
字号:
Attribute VB_Name = "GetCName"
Option Explicit

#If UNICODE Then
    Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameW" (ByVal lpBuffer As Long, nSize As Long) As Long
#Else
    Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#End If

Sub GetComputerName_test()
    Dim Name As String, Length As Long
    
    Length = 255
    Name = String(Length, 0)
#If UNICODE Then
    GetComputerName StrPtr(Name), Length
#Else
    GetComputerName Name, Length
#End If
    Name = Left(Name, Length)
    MsgBox "此一电脑的名称=" & Name, , "GetComputerName"
End Sub

Sub Main()
    GetComputerName_test
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -