vb如果用窗口句柄获取窗口标题名称

2024-12-23 02:37:43
推荐回答(1个)
回答1:

Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Sub Command1_Click()
Dim Tlong as long,s as String
Tlong=GetWindowTextLength(hwnd)+1
s=String(Tlong,chr(0)) '必须要的
GetWindowText hwnd,s,Tlong
Msgbox s
End Sub
hwnd是你获得的窗体句柄,s就是你要的窗体标题了