‘ 声明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
获取计算机名
时间: 2024-10-08 03:21:10
获取计算机名的相关文章
[python]获取计算机名
方法一: import ctypes import os #获取计算机名 def getname(): pcName = ctypes.c_char_p(''.encode('utf-8')) pcSize = 16 pcName = ctypes.cast(pcName, ctypes.c_char_p) try: ctypes.windll.kernel32.GetComputerNameA(pcName, ctypes.byref(ctypes.c_int(pcSize))) except
[Java]通过java获取计算机名
通过java获取计算机名 String hostname = "Unknown"; try { InetAddress addr; addr = InetAddress.getLocalHost(); hostname = addr.getHostName(); } catch (UnknownHostException ex) { System.out.println("Hostname can not be resolved"); } logger.info(&
VC获取计算机名和IP地址
void GetPcNameAndIp(CString &strPCName,vector<CString> &vIp) { vIp.clear(); WSADATA wsadata; WORD dwVersionRequested; int err = WSAStartup(dwVersionRequested,&wsadata); char hostname[128]; if(gethostname(hostname,128)==0) { strPCName.For
AutoCAD.Net/C#.Net QQ群:193522571 WINFORM获取计算机名、域名、用户名
string MachineName = System.Environment.MachineName; string UserDomainName = System.Environment.UserDomainName; string UserName = System.Environment.UserName;
C# 获取本机CPU序列号,MAC地址,硬盘ID,本机IP地址,计算机名,物理内存,PC类型
首先引入服务 然后 调用 本文转载自http://blog.sina.com.cn/s/blog_7eeb43210101hf7f.html public class Computer { public static string CpuID; //1.cpu序列号 public static string MacAddress; //2.mac序列号 public static string DiskID; //3.硬盘id public static string IpAddress; //
Java 获取计算机参数[IPvsMAC]
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.ArrayList; import java.util.Formatter; import java.util.List; import java.uti
JAVA获取计算机CPU、硬盘、主板、网络等信息
通过使用第三方开源jar包sigar.jar我们可以获得本地的信息 1.下载sigar.jar sigar官方主页 sigar-1.6.4.zip 2.按照主页上的说明解压包后将相应的文件copy到java路径.比如windows32位操作系统需要将lib中sigar-x86-winnt.dll文件拷贝到java SDK目录的bin内 参考官方主页上的配置项. File Language Description Required sigar.jar Java Java API Yes (for
VB-获取本机计算机名,登录名、ip地址
真的是很简单,执行结果:Computer:不平凡总在于坚持 User:Administrator IP:192.168.0.111 '获取计算机名.用户名.本机ip Dim LocalInfo As String Dim strLocalIP As String Dim winIP As Object LocalInfo = LocalInfo & " Computer:" & Environ("computername") LocalInfo
C#获取本地计算机名,IP,MAC地址,硬盘ID
using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebPa