VB获取窗口地址栏内容
http://zhidao.baidu.com/question/84802747.html
VB如何获取窗口地址栏内容
就是比如我打开D盘的aaa文件夹,窗口地址栏就是显示D:\aaa,请问我要怎么用VB写程序来获取窗口地址栏的内容?(不是IE的地址栏)
若打开了两个窗口,比如D盘的aaa文件夹和E盘的bbb文件夹下的ccc文件夹都打开的话,点击command1,text1就显示:
D:\aaa
E:\bbb\ccc
请大家帮忙下,谢谢!
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDFIRST = 0
Private Const WM_GETTEXT = &HD
Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Function GetWindowList() As String
Dim hwnd As Long
Dim s As String
hwnd = Me.hwnd
hwnd = GetWindow(hwnd, GW_HWNDFIRST)
While hwnd <> 0
s = String(256, Chr(0))
GetClassName hwnd, s, 255
s = Replace(s, Chr(0), "")
If s = "CabinetWClass" Then
GetWindowList = GetWindowList & GetUrl(hwnd) & vbCrLf
End If
hwnd = GetNextWindow(hwnd, GW_HWNDNEXT)
Wend
End Function
Private Function GetUrl(hwnd As Long) As String
Dim NexthWnd As Long
Dim s As String
NexthWnd = 0
NexthWnd = FindWindowEx(hwnd, NexthWnd, vbNullString, vbNullString)
While NexthWnd <> 0
s = String(256, Chr(0))
GetClassName NexthWnd, s, 255
s = Replace(s, Chr(0), "")
If s = "Edit" Then
相关文档:
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
& ......
珍贵vb函数列表
Variant 变量的内部表示:
_______________________________________________________________
符号常量 值 内部表示 字节数
V_EMPTY 0 Empty
V_NULL 1 Null
V_INTEGER 2 Interger 2
V_LONG 3 Long 4
V_SINGLE 4 Single 4
V_DOUBLE 5 Double 8
V_CURRENCY 6 Currency 8
V_DATE 7 Date 8
V_STRI ......
Option Explicit
Private Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Private Declare Function SetCursor Lib "user32.dll" (ByVal hCursor As Long) As Long
Private Const IDC_HAND As Long = 32649
Private myHand_handle ......
无意中发现VB For循环的一个特点:在循环体中,企图改变循环终止变量使之提前退出循环是徒劳的。
Private Sub Form_Load()
Dim s(0 To 4) As String
Dim N As Integer, i As Integer
s(0) = "测试1"
s(1) = "测试2"
s(2) = "测试3"
s(3) = "测试4"
s(4) = "测试5 ......