3、聲明DLL相關(guān)函數(shù)
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" (ByVal hWnd As IntPtr) As Boolean
Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Integer) As Integer
Private Declare Function GetDlgItem Lib "user32" (ByVal hwnd As Integer, ByVal nIDDlgItem As Integer) As Integer
'GetCaretPos
Declare Auto Function GetMenu Lib "USER32.DLL" (ByVal hWnd As Integer) As Integer
Declare Auto Function GetSubMenu Lib "USER32.DLL" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
Declare Auto Function GetMenuItemCount Lib "USER32.DLL" (ByVal hMenu As Integer) As Integer
Declare Auto Function GetMenuItemID Lib "USER32.DLL" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
Declare Auto Function RemoveMenu Lib "USER32.DLL" (ByVal hMenu As Integer, ByVal nPos As Integer, ByVal uFlag As Integer) As Integer 'uFlag is MF_BYCOMMAND or MF_BYPOSITION
Declare Auto Function DeleteMenu Lib "USER32.DLL" (ByVal hMenu As Integer, ByVal nPos As Integer, ByVal uFlag As Integer) As Integer 'uFlag is MF_BYCOMMAND or MF_BYPOSITION
Declare Auto Function GetMenuState Lib "USER32.DLL" (ByVal hMenu As Integer, ByVal nPos As Integer, ByVal uFlag As Integer) As Integer 'uFlag is MF_BYCOMMAND or MF_BYPOSITION
Declare Auto Function GetMenuString Lib "USER32.DLL" (ByVal hMenu As Integer, ByVal uIDItem As Integer, ByVal lpString As String, ByValnMaxCount As Integer, ByVal uFlag As Integer) As Integer 'uFlag is MF_BYCOMMAND or MF_BYPOSITION
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Integer, ByVal lpString As String, ByVal cch AsInt32) As Integer
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, _
ByVal wParam As Integer, ByVal lParam As String) As Integer
'查找窗口
'窗口類名
<DllImport("user32.dll")> _
Private Shared Function FindWindow(ByVal strClassName As String, ByVal strWindowName As String) As Integer
'窗口標題
End Function
'在窗口列表中尋找與指定條件相符的第一個子窗口
' handle to parent window
' handle to child window
'窗口類名
<DllImport("user32.dll")> _
Private Shared Function FindWindowEx(ByVal hwndParent As Integer, ByVal hwndChildAfter As Integer, ByVal className As String, ByValwindowName As String) As Integer
' 窗口標題
End Function
<DllImport("user32.DLL")> _
Private Shared Function SendMessage(ByVal hWnd As Integer, ByVal Msg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) AsInteger
End Function
'找出某個窗口的創(chuàng)建者(線程或進程),返回創(chuàng)建者的標志符
<DllImport("user32.dll")> _
Private Shared Function GetWindowThreadProcessId(ByVal hwnd As Integer, ByRef processId As Integer) As Integer
End Function
'打開一個已存在的進程對象,并返回進程的句柄
<DllImport("kernel32.dll")> _
Private Shared Function OpenProcess(ByVal dwDesiredAccess As UInteger, ByVal bInheritHandle As Boolean, ByVal processId As Integer) AsInteger
End Function
'為指定的進程分配內(nèi)存地址:成功則返回分配內(nèi)存的首地址
<DllImport("kernel32.dll")> _
Private Shared Function VirtualAllocEx(ByVal hProcess As Integer, ByVal lpAddress As IntPtr, ByVal dwSize As UInteger, ByVal flAllocationTypeAs UInteger, ByVal flProtect As UInteger) As Integer
End Function
'從指定內(nèi)存中讀取字節(jié)集數(shù)據(jù)
'被讀取者的進程句柄
'開始讀取的內(nèi)存地址
'數(shù)據(jù)存儲變量
'要寫入多少字節(jié)
<DllImport("kernel32.dll")> _
Private Shared Function ReadProcessMemory(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As IntPtr, ByVal nSizeAs Integer, ByRef vNumberOfBytesRead As UInteger) As Boolean
'讀取長度
End Function
'將數(shù)據(jù)寫入內(nèi)存中
'由OpenProcess返回的進程句柄
'要寫的內(nèi)存首地址,再寫入之前,此函數(shù)將先檢查目標地址是否可用,并能容納待寫入的數(shù)據(jù)
'指向要寫的數(shù)據(jù)的指針
'要寫入的字節(jié)數(shù)
<DllImport("kernel32.dll")> _
Private Shared Function WriteProcessMemory(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As IntPtr, ByVal nSizeAs Integer, ByRef vNumberOfBytesRead As UInteger) As Boolean
End Function
<DllImport("kernel32.dll")> _
Private Shared Function CloseHandle(ByVal handle As Integer) As Boolean
End Function
'在其它進程中釋放申請的虛擬內(nèi)存空間
'目標進程的句柄,該句柄必須擁有PROCESS_VM_OPERATION的權(quán)限
'指向要釋放的虛擬內(nèi)存空間首地址的指針
<DllImport("kernel32.dll")> _
Private Shared Function VirtualFreeEx(ByVal hProcess As Integer, ByVal lpAddress As Integer, ByVal dwSize As UInteger, ByVal dwFreeType AsUInteger) As Boolean
'釋放類型
End Function
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As String, ByVal cch AsInt32) As Integer
''' <summary>
''' LVITEM結(jié)構(gòu)體,是列表視圖控件的一個重要的數(shù)據(jù)結(jié)構(gòu)
''' 占空間:(int)x7=28個byte
''' </summary>
Private Structure LVITEM
'結(jié)構(gòu)體
Public mask As Integer
'說明此結(jié)構(gòu)中哪些成員是有效的
Public iItem As Integer
'項目的索引值(可以視為行號)從開始
Public iSubItem As Integer
'子項的索引值(可以視為列號)從開始
Public state As Integer
'子項的狀態(tài)
Public stateMask As Integer
'狀態(tài)有效的屏蔽位
Public pszText As IntPtr
'主項或子項的名稱
Public cchTextMax As Integer
'pszText所指向的緩沖區(qū)大小
End Structure
Private Structure HDITEM
Dim mask As Integer
Dim cxy As Integer
Dim pszText As IntPtr
Dim hbm As Integer
Dim cchTextMax As Integer
Dim fmt As Integer
Dim lParam As Integer
Dim iImage As Integer
Dim iOrder As Integer
End Structure
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。