用VB6.0编写自我升级的程序(一)(4)
中华网科技 http://tech.china.com
2005-06-20 13:38:17
|
|
|
‘ 这里是通用模块,放置API函数以及公用函数
‘
‘ ------------------------------------------
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal lSize As Long, ByVal lpFilename As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As Any, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFilename As String) As Long
Public Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFilename As String) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_Close = &H10
Private Const gintMAX_SIZE% = 255 ‘Maximum buffer size
Public UpdateIniPath As String
‘ ===============================================
‘ 从资源文件中提取文件
‘
‘ ===============================================
Public Function SaveFileFromRes(vntResourceID As Variant, sType As String, sFileName As String) As Boolean
Dim bytImage() As Byte
Dim iFileNum As Integer
On Error GoTo SaveFileFromRes_Err
SaveFileFromRes = True
bytImage = LoadResData(vntResourceID, sType)
iFileNum = FreeFile
Open sFileName For Binary As iFileNum
Put #iFileNum, , bytImage
Close iFileNum
Exit Function
SaveFileFromRes_Err:
SaveFileFromRes = False: Exit Function
End Function
‘ ===============================================
‘ 从缓冲区中读取字符串
‘
‘ ===============================================
Private Function StringFromBuffer(Buffer As String) As String
Dim nPos As Long
nPos = InStr(Buffer, vbNullChar)
If nPos > 0 Then
StringFromBuffer = Left$(Buffer, nPos - 1)
Else
StringFromBuffer = Buffer
End If
End Function
‘ ===============================================
首页 上页 | ...1| 2 | 3 | 4 | 5 | 下页 尾页 共 5 页 |