已经通过FindWindow找到窗体句柄,现在要取窗体文件路径+文件名
谢谢各位,,请帮我下
[取窗体文件路径+文件名]
没能理解.
是与窗体程序文件有关的文件路径?
程序代码:Option Explicit Private Declare Function GetWindowModuleFileName Lib "user32" (ByVal hWnd As Long, ByVal lpszFileName As String, ByVal cchFileNameMax As Long) As Long Private Sub Form_Load() Dim sBuf$ sBuf = String$(261, 0) GetWindowModuleFileName Me.hWnd, sBuf, 260 sBuf = Left$(sBuf, InStr(1, sBuf, vbNullChar) - 1) Debug.Print sBuf End Sub= =;
程序代码:Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowModuleFileName Lib "user32" (ByVal hWnd As Long, ByVal lpszFileName As String, ByVal cchFileNameMax As Long) As Long
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim lhWnd As Long
lhWnd = FindWindow("ShImgVw:CPreviewWnd", vbNullString)
If lhWnd Then
Dim sBuf$
sBuf = String$(261, 0)
GetWindowModuleFileName lhWnd , sBuf, 260
sBuf = Left$(sBuf, InStr(1, sBuf, vbNullChar) - 1)
Debug.Print sBuf
End If
End Sub