よく見かけるVBサンプル集
BACK -Page-Next- NEXT
[00〜09] [10〜19] [20〜29] [30〜39] [40〜49]
[50〜59] [60〜69] [70〜79] [80〜89] [90〜99]
MENU 60〜69
<2009/05/26>
いまだに業務用ソフトでVB6が使われてたりするので
今後も更新していきます。
60指定したプロセスからInteger型(2byte)読む API
61指定したプロセスからLong型(4byte)読む API
62指定したプロセスからSingle型(32bit浮動小数)を読む API
63指定したプロセスからDouble型(64bit浮動小数)を読む API
64指定したプロセスからString型(文字列)を読む API
65欠番
66コード内に含まれる、特定KEYを含むリンクを抽出する New
67準備中
68準備中
共通定数
MAX_PATH = 260
使用API |
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesRead As Long) As Long |
使用例
x =GetProcessInteger(zzz,&h006DA484)
以下を標準モジュールへ追加 |
Function
GetProcessInteger(ByVal hProc
As Long, ByVal Addr
As Long) As Integer '指定したプロセスから2byte読む Dim bRet As Long Dim dwRead As Long Dim res As Integer If hProc = 0 Then Exit Function bRet = ReadProcessMemory(hProc, Addr, res, 4, dwRead) GetProcessInteger = res End Function |
使用API |
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesRead As Long) As Long |
使用例
x =GetProcessLong(zzz,&h006DA484)
以下を標準モジュールへ追加 |
Function
GetProcessLong(ByVal hProc
As Long, ByVal Addr
As Long) As
Long '指定したプロセスから4byte読む Dim bRet As Long Dim dwRead As Long Dim res As Integer If hProc = 0 Then Exit Function bRet = ReadProcessMemory(hProc, Addr, res, 4, dwRead) GetProcessLong= res End Function |
指定したプロセスからSingle型(32bit浮動小数)を読む
使用API |
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesRead As Long) As Long |
使用例
x =GetProcessSingle(zzz,&h006DA484)
以下を標準モジュールへ追加 |
Function
GetProcessSingle(ByVal hProc
As Long, ByVal Addr
As Long) As
Single '指定したプロセスから32bit浮動小数を読む Dim bRet As Long Dim dwRead As Long Dim res As Single If hProc = 0 Then Exit Function bRet = ReadProcessMemory(hProc, Addr, res, 4, dwRead) GetProcessSingle = res End Function |
指定したプロセスからDouble型(64bit浮動小数)を読む
使用API |
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesRead As Long) As Long |
使用例
x =GetProcessDouble(zzz,&h006DA484)
以下を標準モジュールへ追加 |
Function
GetProcessDouble(ByVal hProc
As Long, ByVal Addr
As Long) As
Double '指定したプロセスから64bit浮動小数を読む Dim bRet As Long Dim dwRead As Long Dim res As Double, b(7) As Byte If hProc = 0 Then Exit Function bRet = ReadProcessMemory(hProc, Addr, b(0), 8, dwRead) bRet = ReadProcessMemory(hProc, Addr, res, 8, dwRead) GetProcessDouble = res End Function |
使用API |
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesRead As Long) As Long
Const MAX_PATH As Long = 260 |
使用例
x =GetProcessString(zzz,&h006DA484)
以下を標準モジュールへ追加 |
Function
GetProcessString(ByVal hProc
As Long, ByVal Addr
As Long) As
String '指定したプロセスから文字列を読む Dim i As Integer Dim bRet As Long, dwRead As Long Dim Temp$, Temp2$ Dim res As Long If hProc = 0 Then Exit Function Temp = String(MAX_PATH, " ") bRet = ReadProcessMemory(hProc, Addr, ByVal Temp, MAX_PATH - 1, dwRead) i = InStr(Temp, vbNullChar) If i > 1 Then GetProcessString = Left(Temp, i - 1) End Function |
用途
ゲーム系パラメータの取得なんかにも使え色々使える便利なAPI
ReadProcessMemory
敵のHPを表示する等
使用API |
なし |
含まれる機能 |
コード内に含まれる、特定KEYを含むリンクを抽出する。(単体用) コード内に含まれる、特定KEYを含むリンクを抽出する。(複数用リスト化して返す) 開始文字列と終端文字列に囲まれた文字列を抽出する。 |
使用例
GetSearchKEYLinkAddress("http://list3.auctions.yahoo.co.jp/jp/2084240151-category-leaf.html", "NEC", False, strLst(), iIndex)
strLst()にリンクのリストが格納されます。
以下を標準モジュールへ追加 |
'-------------------------------------------------- 'コード内に含まれる、特定KEYを含むリンクを抽出する。 '-------------------------------------------------- 'strSRC :ソース 'strKEY:検索KEY 結果:抽出リンクアドレス 'bPerfectUnity:true=検索KEY完全一致/false=あいまい '*失敗した場合には、空白が返される '検索KEYは結果には含まれない。 '-------------------------------------------------- Public Function GetSearchKEYLinkAddress( _ ByVal strSRC As String, _ ByVal strKEY As String, _ ByVal bPerfectUnity As Boolean, _ ByRef strLst() As String, _ ByRef intIndex As Integer, _ Optional ByVal bHitEndNotAllList As Boolean) As String 'Aタグ格納用の動的配列用 Dim SLINK() As String Dim sTagStart As String Dim sTagEnd As String Dim i As Long, J As Long Dim iStart As Long Dim iNext As Long Dim iEnd As Long Dim iMax As Long Dim n As Long Dim intA As Long Dim intB As Long Dim S As String Dim sCD As String If 0 < InStr(1, strSRC, "<A ") Then sTagStart = "<A " sTagEnd = "</A>" ElseIf 0 < InStr(1, strSRC, "<a ") Then sTagStart = "<a " sTagEnd = "</a>" Else Exit Function End If strSRC = Replace(strSRC, vbCrLf, " ") intA = Len(sTagStart) 'GetStrByte(sTagStart) intB = Len(sTagEnd) 'GetStrByte(sTagEnd) iMax = Len(strSRC) S = strSRC If Not bPerfectUnity Then S = LCase(S) sTagStart = LCase(sTagStart) sTagEnd = LCase(sTagEnd) End If iMax = Len(strSRC) S = strSRC strSRC = LCase(strSRC) If bHitEndNotAllList Then For i = 0 To 9999 intA = InStr(1, strSRC, sTagStart) intB = InStr(1, strSRC, sTagEnd) If intA = 0 Or intB = 0 Then Exit For sCD = GetSpaceCharacterAtoB(strSRC, sTagStart, sTagEnd, True) If Len(sCD) = 0 Then Exit For ReDim Preserve SLINK(J) As String SLINK(J) = sCD If 0 < InStr(1, strSRC, sTagStart & sCD & sTagEnd) Then strSRC = Replace(strSRC, sTagStart & sCD & sTagEnd, "", , 1) Else 'タグが不正のため、続行不可 Exit For End If If bPerfectUnity Then n = InStr(1, SLINK(i), ">" & strKEY) Else strKEY = LCase(strKEY) n = InStr(1, SLINK(i), strKEY) End If If n > 0 Then Exit For J = J + 1 DoEvents Next i strLst = SLINK() 'KEY HIT Else For i = 0 To 9999 intA = InStr(1, strSRC, sTagStart) intB = InStr(1, strSRC, sTagEnd) If intA = 0 Or intB = 0 Then Exit For sCD = GetSpaceCharacterAtoB(strSRC, sTagStart, sTagEnd, True) If Len(sCD) = 0 Then Exit For ReDim Preserve SLINK(J) As String SLINK(J) = sCD If 0 < InStr(1, strSRC, sTagStart & sCD & sTagEnd) Then strSRC = Replace(strSRC, sTagStart & sCD & sTagEnd, "", , 1) Else 'タグが不正のため、続行不可 Exit For End If J = J + 1 DoEvents Next i strLst = SLINK() 'KEY HIT For i = 0 To UBound(SLINK) If bPerfectUnity Then J = InStr(1, SLINK(i), ">" & strKEY) Else strKEY = LCase(strKEY) J = InStr(1, SLINK(i), strKEY) End If If J > 0 Then Exit For Next End If If i < 0 Then Exit Function intIndex = i 'アドレス部分の抽出 GetSearchKEYLinkAddress = GetSpaceCharacterAtoB(SLINK(intIndex), "href=""", """>", True, False) End Function '-------------------------------------------------- '-------------------------------------------------- ’----------以下共通関数---------------- |