推荐回答
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
提示您:回答为网友贡献,仅供参考。