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

📄 form1.frm

📁 把信息写到自身的Exe文件中,并能读取
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "把数据写入自身"
   ClientHeight    =   4800
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4470
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   4800
   ScaleWidth      =   4470
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame1 
      Caption         =   "New Username"
      Height          =   3015
      Left            =   120
      TabIndex        =   6
      Top             =   1680
      Width           =   4095
      Begin VB.TextBox Text3 
         Height          =   375
         Left            =   1080
         TabIndex        =   3
         Top             =   1320
         Width           =   2775
      End
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   1080
         TabIndex        =   2
         Top             =   840
         Width           =   2775
      End
      Begin VB.CommandButton Command1 
         Caption         =   "写入"
         Default         =   -1  'True
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   1200
         TabIndex        =   4
         Top             =   2040
         Width           =   2655
      End
      Begin VB.TextBox Text1 
         Height          =   375
         Left            =   1080
         TabIndex        =   1
         Top             =   360
         Width           =   2775
      End
      Begin VB.Label Label6 
         Caption         =   "Product key:"
         Height          =   375
         Left            =   120
         TabIndex        =   13
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label Label4 
         Caption         =   "Real name:"
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   960
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "Username:"
         Height          =   255
         Left            =   120
         TabIndex        =   7
         Top             =   480
         Width           =   855
      End
   End
   Begin VB.Label Label7 
      Caption         =   "未经修改。写入的数据不能为汉字"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   1215
      Left            =   3840
      TabIndex        =   14
      Top             =   120
      Width           =   615
   End
   Begin VB.Label lblKey 
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   1200
      TabIndex        =   12
      Top             =   1080
      Width           =   2535
   End
   Begin VB.Label Label5 
      Caption         =   "Product Key:"
      Height          =   255
      Left            =   120
      TabIndex        =   11
      Top             =   1080
      Width           =   1095
   End
   Begin VB.Label lblName 
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   1200
      TabIndex        =   9
      Top             =   600
      Width           =   2535
   End
   Begin VB.Label Label3 
      Caption         =   "Real name:"
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   600
      Width           =   855
   End
   Begin VB.Label lblUser 
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   1200
      TabIndex        =   5
      Top             =   120
      Width           =   2535
   End
   Begin VB.Label Label1 
      Caption         =   "Username:"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   855
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'欢迎你下载使用本代码,本份代码由程序太平洋提供下载学习之用
'声明:
'1.本站所有代码的版权归原作者所有,如果你使用了在本站下载的源代码
'  引起的一切纠纷(后果)与本站无关,请您尊重原作者的劳动成果!
'2.若本站在代码上有侵权之处请您与站长联系,站长会及时更正。
'网站:http://www.daima.com.cn
'程序太平洋:http://www.5ivb.net
'Email:dapha@etang.com
'CopyRight 2001-2005 By WangFeng
'整理时间:2005-1-31 4:21:58

Dim MainFile As String
Dim AlterFile As String
Dim TempStr As Byte
Dim strUser As String
Dim strName As String
Dim strKey As String
Dim OffsetStep As Integer
Dim Record As Integer
Private Sub Command1_Click()
    Dim TempByte As Byte
    Dim UserData(20) As Byte
    OffsetStep = 40
    MainFile = App.Path & "\" & App.EXEName & ".exe"
    AlterFile = App.Path & "\" & App.EXEName & "1.exe"
    Open MainFile For Binary Access Read As #1
    Open AlterFile For Binary Access Write As #2
    For i = 1 To LOF(1)
        Get #1, i, TempByte
        Put #2, i, TempByte
    Next i
    Close #1
    For i = 1 To Len(Text1.Text)
        UserData(i) = Asc(Mid(Text1.Text, i, 1))
    Next i
    If Len(Text1.Text) < 20 Then
        For i = Len(Text1.Text) + 1 To 20
            UserData(i) = Asc(" ")
        Next i
    End If
    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(2) - OffsetStep
        Put #2, Record, UserData(i)
    Next i

    'NOW FOR REAL NAME
    OffsetStep = 60
    For i = 1 To Len(Text2.Text)
        UserData(i) = Asc(Mid(Text2.Text, i, 1))
    Next i

    If Len(Text2.Text) < 20 Then
        For i = Len(Text2.Text) + 1 To 20
            UserData(i) = Asc(" ")
        Next i
    End If

    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(2) - OffsetStep
        Put #2, Record, UserData(i)
    Next i


    'NOW FOR KEY

    OffsetStep = 80
    For i = 1 To Len(Text3.Text)
        UserData(i) = Asc(Mid(Text3.Text, i, 1))
    Next i

    If Len(Text3.Text) < 20 Then
        For i = Len(Text3.Text) + 1 To 20
            UserData(i) = Asc(" ")
        Next i
    End If

    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(2) - OffsetStep
        Put #2, Record, UserData(i)
    Next i

    Close #2

    Dim strBat As String

    strBat = "del " & App.EXEName & ".exe" & vbCrLf & "ren " & App.EXEName & "1.exe" & " " & App.EXEName & ".exe" & vbCrLf & App.EXEName & ".exe"



    Open App.Path & "\runbat.bat" For Output As #1
    Print #1, strBat
    Close #1

    Shell App.Path & "\runbat.bat", vbHide
    End

End Sub

Private Sub Form_Load()
    MainFile = App.Path & "\" & App.EXEName & ".exe"

    AlterFile = App.Path & "\" & App.EXEName & "1.exe"

    On Error GoTo 10

    Kill App.Path & "\runbat.bat"




    Open MainFile For Binary Access Read As #1
    OffsetStep = 40

    'get username
    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(1) - OffsetStep
        Get #1, Record, TempStr
        strUser = strUser & Chr(TempStr)
    Next i

    'get real name
    OffsetStep = 60
    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(1) - OffsetStep
        Get #1, Record, TempStr
        strName = strName & Chr(TempStr)
    Next i

    'get key
    OffsetStep = 80
    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(1) - OffsetStep
        Get #1, Record, TempStr
        strKey = strKey & Chr(TempStr)
    Next i
    Close #1

    'display data
    lblUser.Caption = strUser
    lblName.Caption = strName
    lblKey.Caption = strKey
    Exit Sub


10:
    Open MainFile For Binary Access Read As #1
    OffsetStep = 40

    'get username
    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(1) - OffsetStep
        Get #1, Record, TempStr
        strUser = strUser & Chr(TempStr)
    Next i

    'get real name
    OffsetStep = 60
    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(1) - OffsetStep
        Get #1, Record, TempStr
        strName = strName & Chr(TempStr)
    Next i

    '获取密钥
    OffsetStep = 80
    For i = 1 To 20
        OffsetStep = OffsetStep - 1
        Record = LOF(1) - OffsetStep
        Get #1, Record, TempStr
        strKey = strKey & Chr(TempStr)
    Next i

    Close #1

    '显示数据
    lblUser.Caption = strUser
    lblName.Caption = strName
    lblKey.Caption = strKey

End Sub

⌨️ 快捷键说明

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