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调用系统的"打印机设置"和"页面设置".
Option Explicit
Const FW_NORMAL = 400
Const DEFAULT_CHARSET = 1
Const OUT_DEFAULT_PRECIS = 0
Const CLIP_DEFAULT_PRECIS = 0
Const DEFAULT_QUALITY = 0
Const DEFAULT_PITCH = 0
Const FF_ROMAN = 16
Const CF_PRINTERFONTS = &H2
Const C ......