Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Dim pid As Long
Private Sub Command1_Click()
Dim proc As Long
proc = FindWindow(vbNullString, Text1.Text)
If proc > 0 Then
GetWindowThreadProcessId proc, pid
Form1.Caption = "遊戲啟動! pid = " & pid
Else
Form1.Caption = "遊戲未啟動"
End If
End Sub
Private Sub Command2_Click()
Dim proc As Long
Dim i As Integer
proc = FindWindow(vbNullString, Text1.Text)
If proc > 0 Then
i = 1
Do While FindWindow(vbNullString, Text1.Text & i) <> 0
DoEvents
i = i + 1
Loop
Call SetWindowText(proc, Text1.Text & i)
MsgBox "修改完成,請開啟另一個完美世界主程式。"
Else
MsgBox "請先執行完美世界主程式。"
End If
End Sub
大大的教學用偵錯>逐行試程式時
第1行就錯了--->Private Sub Command1_Click()
這對新手來說就不能再自己學寫了
因不知下面寫的錯在那
這會是大大寫錯了什麼才會這樣嗎?
還是大大沒有用偵錯來看程式?
要沒錯應改那裡?
因為這是好的開始 |