|
- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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 Long) As Long
- Private Const WM_CLOSE As Long = &H10
- Sub 打开指定路径的图片()
- Dim sPic As String
- Dim hWnd As Long
-
- sPic = "C:\Users\Administrator\Desktop\20231208114719.jpg"
- picname = Split(sPic, "")(UBound(Split(sPic, "")))
-
- ' 打开图片
- Shell "rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen " & sPic, vbNormalFocus
-
- ' 等待一段时间,确保照片查看器已经打开
- Application.Wait Now + TimeValue("00:00:02")
-
- ' 获取照片查看器的窗口句柄
- hWnd = FindWindow(vbNullString, picname & " - Windows 照片查看器")
-
- ' 如果找到窗口句柄,则发送关闭消息
- If hWnd <> 0 Then
- SendMessage hWnd, WM_CLOSE, 0, 0
- End If
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|