用VB写一个小程序

需要一个程序实现如下功能,双击这个程序然后在当前目录生成一个文本,文本里面的内容是当前电脑CPU序列信息。大致过程是这样:运行程序---生成cpu序列信息文本(如:cpu... 需要一个程序实现如下功能,
双击这个程序然后在当前目录生成一个文本,文本里面的内容是当前电脑CPU序列信息。
大致过程是这样:运行程序---生成cpu序列信息文本(如:cpu.txt)---结束
文本里面只有一串数字。软件运行的时候,不需要任何界面,或显示。也不需要是、否之类
就是一运行当前目录就会出现一个cpu.txt 就可以了
我在网上找到一个VB源码,但是不会用,高手请看看:expo020.com/cpu.rar
我不会用VB,哪位高手做好之后发给我一下:achao07@qq.com
展开
 我来答
ahjzysq
2010-12-30 · TA获得超过221个赞
知道答主
回答量:65
采纳率:0%
帮助的人:41.8万
展开全部
'取得CPU序列号

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "高轿燃GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0

Private Sub Form_Load()
Form1.Hide
Dim len5 As Long, aa As Long
Dim cmprName As String
Dim osver As OSVERSIONINFO
'取得Computer Name
Open "cpu.txt" For Output As #1
cmprName = String(255, 0)
len5 = 256
aa = GetComputerName(cmprName, len5)
cmprName = Left(cmprName, InStr(1, cmprName, Chr(0)) - 1)
Computer = cmprName '取得CPU端口号
Set CPUs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").ExecQuery("select * from Win32_Processor")
For Each mycpu In CPUs
Print #1, mycpu.ProcessorId
Next
Close #1
End
End Sub
这是在你的基戚虚础上改的,还有把form1的visible的帆州值改为false
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
sunyongzhen
2010-12-30 · TA获得超过306个赞
知道答主
回答量:66
采纳率:0%
帮助的人:70.7万
展开全部
用这个吧链唯侍:

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "山胡GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0

Private Sub Form_Load()
Dim len5 As Long, aa As Long
Dim cmprName As String, cpuID As String
Dim osver As OSVERSIONINFO
cmprName = String(255, 0)
len5 = 256
aa = GetComputerName(cmprName, len5)
cmprName = Left(cmprName, InStr(1, cmprName, Chr(0)) - 1)
Computer = cmprName
Set CPUs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").ExecQuery("select * from Win32_Processor")
For Each mycpu In CPUs
cpuID = mycpu.ProcessorId
Next
Open App.Path & "棚吵\CPU.txt" For Append As #1
Print #1, cpuID
Close #1
End
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
沙慧月03
2010-12-30 · TA获得超过2157个赞
知道大有可为答主
回答量:2717
采纳率:100%
帮助的人:3617万
展开全部
Private Sub Form_Load()
Form1.Visible = False
Dim cpuSet
Dim cpu
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each cpu In cpuSet
a = (cpu.ProcessorId)
Next
Open "d:\cpu.txt" For Output As #1
Print #1, a
Close
End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式