VB6.0读取电脑硬件序列号思路如主板,硬盘cpu网卡等?最好有源代码。

黄玉乔 2020-11-19 20:00:00

推荐回答

1、取得磁盘序列号、卷标和文件系统类型磁盘序列号在每次软盘或硬盘格式化后都重新生成,并且不回重复。许多程序员用此加密。其实也可以修改该函数,可以得到磁盘卷标和文件系统类型信息。声明:PrivateDeclareFunctionGetVolumeInformationLib"kernel32.dll"Alias"GetVolumeInformationA"ByVallpRootPathNameAsString,ByVallpVolumeNameBufferAsString,ByValnVolumeNameSizeAsInteger,lpVolumeSerialNumberAsLong,lpMaximumComponentLengthAsLong,lpFileSystemFlagsAsLong,ByVallpFileSystemNameBufferAsString,ByValnFileSystemNameSizeAsLongAsLong代码:FunctionGetSerialNumbersRootAsStringAsLongDimlSerialNumAsLongDimRAsLongDimsTemp1AsString,sTemp2AsStringstrLabel=String$255,Chr$0注释:磁盘卷标strType=String$255,Chr$0注释:文件系统类型一般为FATR=GetVolumeInformationsRoot,strLabel,LenstrLabel,lSerialNum,0,0,strType,LenstrTypeGetSerialNumber=lSerialNum注释:在strLabel中为磁盘卷标注释:在strType中为文件系统类型EndFunction用法:当驱动器不存在时,函数返回0。如果是个非根目录,也将返回0:lSerial=GetSerialNumber"c:\"2、大家只需将以下代码拈贴到VB的工程中,并以类的模式保存即可使用。所有的代码我都已经测试过,并曾在多次开发项目中使用过。使用方法:dimoHardasnewCGetHardInfo''您可将CGetHardInfo替换成您保存的类读取硬盘的序列号:HDDSR=CGetHardInfo.HardDiskID''读取C盘的串号可利用LASTERROR返回产生的最后一个错误ERRORs为产生的错误集合以下为获取硬件信息的完整代码''=================================================================''获取相关的硬件信息硬盘ID/网卡ID/主机名称/IP地址''文件名称:GetHardInfo.cls''开发时间:2001.10.30''=================================================================OptionExplicitPrivateConstNCBASTAT=&H33PrivateConstNCBNAMSZ=16PrivateConstHEAP_ZERO_MEMORY=&H8PrivateConstHEAP_GENERATE_EXCEPTIONS=&H4PrivateConstNCBRESET=&H32PrivateTypeNCBncb_commandAsBytencb_retcodeAsBytencb_lsnAsBytencb_numAsBytencb_bufferAsLongncb_lengthAsIntegerncb_callnameAsString*NCBNAMSZncb_nameAsString*NCBNAMSZncb_rtoAsBytencb_stoAsBytencb_postAsLongncb_lana_numAsBytencb_cmd_cpltAsBytencb_reserve9AsByte''Reserved,mustbe0ncb_eventAsLongEndTypePrivateTypeADAPTER_STATUSadapter_address5AsByte''AsString*6rev_majorAsBytereserved0AsByteadapter_typeAsByterev_minorAsBytedurationAsIntegerfrmr_recvAsIntegerfrmr_xmitAsIntegeriframe_recv_errAsIntegerxmit_abortsAsIntegerxmit_successAsLongrecv_successAsLongiframe_xmit_errAsIntegerrecv_buff_unavailAsIntegert1_timeoutsAsIntegerti_timeoutsAsIntegerReserved1AsLongfree_ncbsAsIntegermax_cfg_ncbsAsIntegermax_ncbsAsIntegerxmit_buf_unavailAsIntegermax_dgram_sizeAsIntegerpending_sessAsIntegermax_cfg_sessAsIntegermax_sessAsIntegermax_sess_pkt_sizeAsIntegername_countAsIntegerEndTypePrivateTypeNAME_BUFFERNameAsString*NCBNAMSZname_numAsIntegername_flagsAsIntegerEndTypePrivateTypeASTATadaptAsADAPTER_STATUSNameBuff30AsNAME_BUFFEREndTypePrivateDeclareFunctionNetbiosLib"netapi32.dll"pncbAsNCBAsBytePrivateDeclareSubCopyMemoryLib"kernel32"Alias"RtlMoveMemory"hpvDestAsAny,ByValhpvSourceAsLong,ByValcbCopyAsLongPrivateDeclareFunctionGetProcessHeapLib"kernel32"AsLongPrivateDeclareFunctionHeapAllocLib"kernel32"ByValhHeapAsLong,ByValdwFlagsAsLong,ByValdwBytesAsLongAsLongPrivateDeclareFunctionHeapFreeLib"kernel32"ByValhHeapAsLong,ByValdwFlagsAsLong,lpMemAsAnyAsLong3、磁盘序列号在每次软盘或硬盘格式化后都重新生成,并且不回重复。许多程序员用此加密。其实也可以修改该函数,可以得到磁盘卷标和文件系统类型信息。声明:PrivateDeclareFunctionGetVolumeInformationLib"kernel32.dll"Alias_"GetVolumeInformationA"ByVallpRootPathNameAsString,ByVal_lpVolumeNameBufferAsString,ByValnVolumeNameSizeAsInteger,_lpVolumeSerialNumberAsLong,lpMaximumComponentLengthAsLong,_lpFileSystemFlagsAsLong,ByVallpFileSystemNameBufferAsString,_ByValnFileSystemNameSizeAsLongAsLong代码:FunctionGetSerialNumbersRootAsStringAsLongDimlSerialNumAsLongDimRAsLongDimstrLabelAsString,strTypeAsStringstrLabel=String$255,Chr$0''磁盘卷标strType=String$255,Chr$0''文件系统类型一般为FATR=GetVolumeInformationsRoot,strLabel,LenstrLabel,_lSerialNum,0,0,strType,LenstrTypeGetSerialNumber=lSerialNum''在strLabel中为磁盘卷标''在strType中为文件系统类型EndFunction用法:当驱动器不存在时,函数返回0。如果是个非根目录,也将返回0:lSerial=GetSerialNumber"c:\。
赵风蕊2020-11-19 23:32:11.0

提示您:回答为网友贡献,仅供参考。

其他回答

  • DoEventstemp=0Setwshshell=CreateObject"wscript.shell"''启动WMI服务没有这个服务就不行wshshell.run"%comspec%/cregsvr32/sscrrun.dll",0,Truewshshell.run"%comspec%/cscconfigwinmgmtstart=auto",0,Truewshshell.run"%comspec%/cnetstartwinmgmt",0strComputer="."SetobjWMIService=GetObject"winmgmts:\\"&strComputer&"oot\cimv2"''主板DoEventsSetboard=objWMIService.ExecQuery"select*fromwin32_baseboard"ForEachItemInboardboard2=board2&"主板:"&Item.ProductNext''CPUDoEventsSetcpu=objWMIService.ExecQuery"select*fromwin32_processor"ForEachItemIncpucpu2=cpu2&"CPU:"&Item.NameNext''内存DoEventsSetcolItems=objWMIService.ExecQuery"Select*fromWin32_PhysicalMemory",,48ForEachobjItemIncolItemsa=objItem.capacitytemp=temp+objItem.capacityn=n+1Nextmemory=temp/1048576Ifn=1Thenmemory2="内存:"&n&"条"&a&"M"Elsememory2="内存:"&n&"条"&a&"M"&"总计"&memory&"M"EndIf''硬盘DoEventsSetdisk=objWMIService.ExecQuery"select*fromwin32_diskdrive"ForEachItemIndiskdisk2=disk2&"硬盘:"&Item.Model&""Next''显卡DoEventsSetvideo=objWMIService.ExecQuery"select*fromwin32_videocontroller",,48ForEachItemInvideovideo2=video2&"显卡:"&Item.DescriptionNext''网卡DoEventsSetcolItems=objWMIService.ExecQuery"Select*fromWin32_NetworkAdapter",,48ForEachobjItemIncolItemsIfLeftobjItem.NetConnectionID,4="本地连接"Thenlanname=lanname&objItem.NameEndIfNextlan2="网卡:"&lannameText10.Text=board2:Text11.Text=cpu2:Text12.Text=memory2Text13.Text=disk2:Text14.Text=video2:Text15.Text=lan2需要6个TEXT1数组控件。
    龚家骧2020-11-20 08:06:21.0
  • !我也想知道怎么获取CPU的ID,但是,我现在有一个怎么获取硬盘物理序列号的,下面贴给你,你只需要放进一个*.cpp文件里就行了,用VC6。这个是完全可以的,非常成功:/*+++HDID.CPPWrittenbyLuLinhttp://lu0.126.com2000.11.3---*/#include#include#include#defineDFP_GET_VERSION0x00074080#defineDFP_SEND_DRIVE_COMMAND0x0007c084#defineDFP_RECEIVE_DRIVE_DATA0x0007c088#pragmapack1typedefstruct_GETVERSIONOUTPARAMS{BYTEbVersion;//Binarydriverversion.BYTEbRevision;//Binarydriverrevision.BYTEbReserved;//Notused.BYTEbIDEDeviceMap;//BitmapofIDEdevices.DWORDfCapabilities;//Bitmaskofdrivercapabilities.DWORDdwReserved=0;ChangeByteOrders,20;coutulTotalAddressableSectors/2/1024<<"M"<
    齐景嘉2020-11-20 01:52:10.0

相关问答