3、聲明DLL相關(guān)函數
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
'查找窗口
'窗口類(lèi)名
<DllImport("user32.dll")> _
Private Shared Function FindWindow(ByVal strClassName As String, ByVal strWindowName As String) As Integer
'窗口標題
End Function
'在窗口列表中尋找與指定條件相符的第一個(gè)子窗口
' handle to parent window
' handle to child window
'窗口類(lèi)名
<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
'找出某個(gè)窗口的創(chuàng )建者(線(xiàn)程或進(jìn)程),返回創(chuàng )建者的標志符
<DllImport("user32.dll")> _
Private Shared Function GetWindowThreadProcessId(ByVal hwnd As Integer, ByRef processId As Integer) As Integer
End Function
'打開(kāi)一個(gè)已存在的進(jìn)程對象,并返回進(jìn)程的句柄
<DllImport("kernel32.dll")> _
Private Shared Function OpenProcess(ByVal dwDesiredAccess As UInteger, ByVal bInheritHandle As Boolean, ByVal processId As Integer) AsInteger
End Function
'為指定的進(jìn)程分配內存地址:成功則返回分配內存的首地址
<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
'從指定內存中讀取字節集數據
'被讀取者的進(jìn)程句柄
'開(kāi)始讀取的內存地址
'數據存儲變量
'要寫(xiě)入多少字節
<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
'讀取長(cháng)度
End Function
'將數據寫(xiě)入內存中
'由OpenProcess返回的進(jìn)程句柄
'要寫(xiě)的內存首地址,再寫(xiě)入之前,此函數將先檢查目標地址是否可用,并能容納待寫(xiě)入的數據
'指向要寫(xiě)的數據的指針
'要寫(xiě)入的字節數
<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
'在其它進(jìn)程中釋放申請的虛擬內存空間
'目標進(jìn)程的句柄,該句柄必須擁有PROCESS_VM_OPERATION的權限
'指向要釋放的虛擬內存空間首地址的指針
<DllImport("kernel32.dll")> _
Private Shared Function VirtualFreeEx(ByVal hProcess As Integer, ByVal lpAddress As Integer, ByVal dwSize As UInteger, ByVal dwFreeType AsUInteger) As Boolean
'釋放類(lèi)型
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結構體,是列表視圖控件的一個(gè)重要的數據結構
''' 占空間:(int)x7=28個(gè)byte
''' </summary>
Private Structure LVITEM
'結構體
Public mask As Integer
'說(shuō)明此結構中哪些成員是有效的
Public iItem As Integer
'項目的索引值(可以視為行號)從開(kāi)始
Public iSubItem As Integer
'子項的索引值(可以視為列號)從開(kāi)始
Public state As Integer
'子項的狀態(tài)
Public stateMask As Integer
'狀態(tài)有效的屏蔽位
Public pszText As IntPtr
'主項或子項的名稱(chēng)
Public cchTextMax As Integer
'pszText所指向的緩沖區大小
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ù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。