是不是想做加密程序?我这里有一个读磁盘序列号的东东,看看能不能用:  大家都知道,当您在命令行中键入“dir”指令后,系统都会读出一个称作Serial Number的十六进制数字。这个数字理论上有上亿种可能,而且很难同时找到两个序列号一样的硬盘。这就是我这种注册方法的理论依据,通过判断指定磁盘的序列号决定该机器的注册号。  要实现该功能,如何获得指定磁盘的序列号是最关键的。在Windows中,有一个GetVolumeInformation的API函数,我们利用这个函数就可以实现。  下面是实现该功能所需要的代码: 
Private Declare Function GetVolumeInformation& Lib "kernel32" _
Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, _
ByVal pVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long)
Private Const MAX_FILENAME_LEN = 256
Public Function DriveSerial(ByVal sDrv As String) As Long
注释:Usage:
注释:Dim ds As Long
注释:ds = DriveSerial("C")
Dim RetVal As Long
Dim str As String * MAX_FILENAME_LEN
Dim str2 As String * MAX_FILENAME_LEN
Dim a As Long
Dim b As Long
GetVolumeInformation sDrv & ":\", str, MAX_FILENAME_LEN, RetVal, _
a, b, str2, MAX_FILENAME_LEN
DriveSerial = RetVal
End Function     
  如果我们需要某个磁盘的序列号的话,只要DriverSerial(该磁盘的盘符)即可。如 DriverASerialNumber=DriverSerial("A")。下面,我们就可以利用返回的磁盘序列号进行加密,需要用到一些数学知识。在这里我用了俄罗斯密码表的加密算法对进行了数学变换的序列号进行加密。下面是注册码验证部分的代码: Public Function IsValidate(ByVal SRC As Long, ByVal Value As String) As Boolean
Dim SourceString As String
Dim NewSRC As Long
For i = 0 To 30
If (SRC And 2 ^ i) = 2 ^ i Then
SourceString = SourceString + "1"
Else
SourceString = SourceString + "0"
End If
Next i
If SRC < 0 Then
SourceString = SourceString + "1"
Else
SourceString = SourceString + "0"
End IfDim Table As String
Dim TableIndex As Integer
注释:================================================================================
注释:这是密码表,根据你的要求换成别的,不过长度要一致
注释:================================================================================
注释:注意:这里的密码表变动后,对应的注册号生成器的密码表也要完全一致才能生成正确的注册号
Table = "JSDJFKLUWRUOISDH;KSADJKLWQ;ABCDEFHIHL;KLADSHKJAGFWIHERQOWRLQH"
注释:================================================================================
Dim Result As String
Dim MidWord As String
Dim MidWordValue As Byte
Dim ResultValue As Byte
For t = 1 To 1
For i = 1 To Len(SourceString)
MidWord = Mid(SourceString, i, 1)
MidWordValue = Asc(MidWord)
TableIndex = TableIndex + 1
If TableIndex > Len(Table) Then TableIndex = 1
ResultValue = Asc(Mid(Table, TableIndex, 1)) Mod MidWordValue
Result = Result + Hex(ResultValue)
Next i
SourceString = Result
Next t
Dim BitTORool As Integer
For t = 1 To Len(CStr(SRC))
BitTORool = SRC And 2 ^ t
For i = 1 To BitTORool
SourceString = Right(SourceString, 1) _
+ Left(SourceString, Len(SourceString) - 1)
Next i
Next t
If SourceString = Value Then IsValidate = True
End Function

解决方案 »

  1.   

    http://www.applevb.com/libvb.htm有一个
    斑竹用VC编写的DLL,可以获得硬盘的型号、序列号以及计算机 ID,带Delphi的源程序,在Win2K下通过,但是没有在Win9X下试过,感兴趣的朋友可以在Win9X 下试一下,或者编写一个VB的范例。
    函数以及定义:
    function ReadPhysicalDrive(driveID:integer;buffer:Pointer;bufLen:integer):integer; stdcall; external 'DiskID.dll' name 'ReadPhysicalDriveInNT';
    获得WinNT下的硬盘型号以及序列号。参数driveID为硬盘的位置,IDE1上的主盘为0,类推到IDE2上的从盘的driveID为3。
    function ReadPhysicalDrive9X(driveID:integer;buffer:Pointer;bufLen:integer):integer; stdcall; external 'DiskID.dll' name 'ReadDrivePortsInWin9X'; 
    获得Win9X下的硬盘型号以及序列号。参数同上
    function getHardDriveComputerID:int64; stdcall; external 'DiskID.dll' name 'getHardDriveComputerID';
    获得计算机的ID 利用这个DLL对我的IBM硬盘返回的值是:
    序列号:         JHYJHT7T352
    型号:IBM-DPTA-371360
      

  2.   

    原则上是不行的,当然如果你知道什么叫木马,正好你又会做的话,那我想应该是可以的。;)
    BYTEHWAY:有没有分送啊?
      

  3.   

    byTheway:
      能不能给我搞一个这样的玩意出来?
      有分给你,放心