⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form111.frm

📁 网卡序列号设计软件注册程序 根据cpu序列号、磁盘序列号设计软件注册程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1111 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "利用网卡号注册软件"
   ClientHeight    =   3885
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6270
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3885
   ScaleWidth      =   6270
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command4 
      Caption         =   "生成注册号"
      Height          =   405
      Left            =   195
      TabIndex        =   10
      Top             =   1695
      Width           =   1275
   End
   Begin VB.CommandButton Command3 
      Caption         =   "生成机器号"
      Height          =   405
      Left            =   195
      TabIndex        =   9
      Top             =   1245
      Width           =   1275
   End
   Begin VB.Frame Frame1 
      Caption         =   "请输入注册码:"
      Height          =   705
      Left            =   180
      TabIndex        =   2
      Top             =   2340
      Width           =   5880
      Begin VB.TextBox Txt 
         Height          =   345
         Index           =   3
         Left            =   4650
         TabIndex        =   14
         Top             =   255
         Width           =   1065
      End
      Begin VB.TextBox Txt 
         Height          =   345
         Index           =   2
         Left            =   3435
         TabIndex        =   6
         Top             =   270
         Width           =   1065
      End
      Begin VB.TextBox Txt 
         Height          =   345
         Index           =   1
         Left            =   2220
         TabIndex        =   5
         Top             =   270
         Width           =   1065
      End
      Begin VB.TextBox Txt 
         Height          =   345
         Index           =   0
         Left            =   1020
         TabIndex        =   4
         Top             =   270
         Width           =   1065
      End
      Begin VB.Label Label1 
         Caption         =   "注册码:"
         ForeColor       =   &H000000FF&
         Height          =   195
         Left            =   225
         TabIndex        =   3
         Top             =   330
         Width           =   795
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "关闭"
      Height          =   645
      Left            =   4170
      TabIndex        =   1
      Top             =   3090
      Width           =   1845
   End
   Begin VB.CommandButton Command1 
      Caption         =   "注册"
      Height          =   645
      Left            =   2445
      TabIndex        =   0
      Top             =   3090
      Width           =   1725
   End
   Begin VB.Label Label5 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      Left            =   1560
      TabIndex        =   13
      Top             =   1740
      Width           =   4380
   End
   Begin VB.Label Label3 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   360
      Left            =   1545
      TabIndex        =   12
      Top             =   1320
      Width           =   4305
   End
   Begin VB.Label Label2 
      Caption         =   "Label2"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   660
      Left            =   195
      TabIndex        =   11
      Top             =   435
      Width           =   6075
   End
   Begin VB.Label Label4 
      Height          =   345
      Left            =   180
      TabIndex        =   8
      Top             =   765
      Width           =   5700
   End
   Begin VB.Label Lbl 
      AutoSize        =   -1  'True
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   360
      Left            =   990
      TabIndex        =   7
      Top             =   585
      Width           =   180
   End
End
Attribute VB_Name = "Form1111"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 Option Explicit
' 字符常数说明
Private Const NCBASTAT = &H33
Private Const NCBNAMSZ = 16
Private Const HEAP_ZERO_MEMORY = &H8
Private Const HEAP_GENERATE_EXCEPTIONS = &H4
Private Const NCBRESET = &H32
' 结构型变量说明
Private Type NCB
  ncb_command As Byte
  ncb_buffer As Long
  ncb_length As Integer
  ncb_callname As String * NCBNAMSZ
  ncb_lana_num As Byte
 End Type
Private Type ADAPTER_STATUS
  adapter_address(5) As Byte
End Type
Private Type NAME_BUFFER
  name As String * NCBNAMSZ
  name_num As Integer
  name_flags As Integer
End Type
Private Type ASTAT
  adapt As ADAPTER_STATUS
  NameBuff(30) As NAME_BUFFER
End Type

' API函数声明
Private Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Function GetProcessHeap Lib "kernel32" () As Long
Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
'读取文件
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


Dim M_Num As String '当前网卡号
Dim P_path As String '注册文件地址
Dim M_ReadNum As String '注册文件中的注册号
Private Sub Command1_Click()
  If Txt(0) <> "123" Or Txt(1) <> "456" Or Txt(2) <> "789" Then
    MsgBox "注册码不正确,请重新输入"
    Txt(0).SetFocus
    Exit Sub
 End If
   WritePrivateProfileString "zc", "zc", M_Num, P_path
    MsgBox "注册成功"
    Form_Load
End Sub

Private Sub Command2_Click()
  End
End Sub

Private Sub Form_Load()
   P_path = App.Path + "\zc.ini"
  Dim myNCB As NCB
  Dim myASTAT As ASTAT, TempASTAT As ASTAT
  Dim pASTAT As Long
    myNCB.ncb_command = NCBRESET
    Netbios myNCB
    myNCB.ncb_command = NCBASTAT
    myNCB.ncb_lana_num = 0
    myNCB.ncb_callname = "*"
    myNCB.ncb_length = Len(myASTAT)

    pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, myNCB.ncb_length)
    myNCB.ncb_buffer = pASTAT
    Netbios myNCB
    CopyMemory myASTAT, myNCB.ncb_buffer, Len(myASTAT)
    M_Num = Hex(myASTAT.adapt.adapter_address(0)) & "-" & Hex(myASTAT.adapt.adapter_address(1)) & "-" & Hex(myASTAT.adapt.adapter_address(2)) & "-" & Hex(myASTAT.adapt.adapter_address(3)) & "-" & Hex(myASTAT.adapt.adapter_address(4)) & "-" & Hex(myASTAT.adapt.adapter_address(5))
    Label2.Caption = M_Num
    HeapFree GetProcessHeap(), 0, pASTAT
    M_ReadNum = GetFromINI("zc", "zc", P_path) '读取注册
    Compare

End Sub
Private Sub Compare() '比较注册码
 If M_ReadNum <> M_Num Then
     MsgBox "你的系统未注册"
     Lbl.Caption = "软件未注册,请注册后使用!"
     Exit Sub
 End If
    Lbl.Caption = "本软件已成功注册"
End Sub
Function GetFromINI(AppName As String, KeyName As String, FileName As String) As String
   Dim RetStr As String
   RetStr = String(255, Chr(0))
   GetFromINI = Left(RetStr, GetPrivateProfileString(AppName, ByVal KeyName, "", RetStr, Len(RetStr), FileName))
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -