标题:怎么实现桌面右击,修改中等图标
只看楼主
czjt8888
Rank: 2
等 级:论坛游民
帖 子:6
专家分:19
注 册:2021-1-25
结帖率:100%
已结贴  问题点数:20 回复次数:7 
怎么实现桌面右击,修改中等图标
怎么实现桌面右击,修改中等图标小图标?
搜索更多相关主题的帖子: 图标 桌面 修改 右击 
2021-01-25 22:25
czjt8888
Rank: 2
等 级:论坛游民
帖 子:6
专家分:19
注 册:2021-1-25
得分:0 
如果修改注册表,则需要重启explorer.exe
reg add "HKCU\Software\Microsoft\Windows\Shell\Bags\1\Desktop" /v "IconSize" /t REG_DWORD /d "0x00000030" /f

刷新桌面没有用
Desktop = FindWindow("Progman", "Program Manager")
PostMessage Desktop, WM_KEYDOWN, vbKeyF5, 0
2021-01-25 22:27
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
得分:0 
注册表修改图标大小的方法:

以下方法XP 32位系统下测试通过。
Win10 64位系统下测试失败。

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]
"Shell Icon Size"="64"


其中,32为小图标 48为中图标 64大图标

重启计算机后效。

[此贴子已经被作者于2021-1-26 15:12编辑过]


心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2021-01-26 15:09
czjt8888
Rank: 2
等 级:论坛游民
帖 子:6
专家分:19
注 册:2021-1-25
得分:0 
回复 3楼 yuma
谢谢回复,不过我知道修改注册表,上面我也给出了一个注册表

但是我不想重启电脑,也不想重启explorer.exe

所以就想问哪个api与修改图标有关
2021-01-26 17:09
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
得分:20 
想不重启explorer.exe,只有模拟人工对键鼠的操作了。
以下代码win10 64位系统下测试通过。
请编译后运行查看效果。

程序代码:
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
Private Sub Form_Load()
Set objSHA = CreateObject("Shell.Application")
objSHA.ToggleDesktop
Set objSHA = Nothing
Sleep 1000
SetCursorPos 0, 0
mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
Sleep 1000
SetCursorPos 45, 13
Sleep 1000
SetCursorPos 270, 36
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End
End Sub


[此贴子已经被作者于2021-1-26 19:24编辑过]


心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2021-01-26 18:44
czjt8888
Rank: 2
等 级:论坛游民
帖 子:6
专家分:19
注 册:2021-1-25
得分:0 
感谢回复,我想的是后台静默修改,而不是模拟鼠标
所以想用api
2021-01-27 16:48
xiaoshi112
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2011-2-10
得分:0 
学习了,谢谢版主
2021-04-01 13:46
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
得分:0 
以下是引用czjt8888在2021-1-27 16:48:27的发言:

感谢回复,我想的是后台静默修改,而不是模拟鼠标
所以想用api

Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Const GWL_STYLE = (-16)
Private Const LVM_FIRST = &H1000
Private Const LVM_SETICONSPACING = LVM_FIRST + 53

Private Sub Command1_Click()
    Dim hWnd As Long
    Dim hListView As Long
    Dim lStyle As Long
    Dim lResult As Long
    Dim iIconSize As Integer
   
    '获取桌面窗口句柄
    hWnd = GetDesktopWindow()
   
    '获取桌面ListView控件句柄
    hListView = FindWindowEx(hWnd, 0, "Progman", vbNullString)
    hListView = FindWindowEx(hListView, 0, "SHELLDLL_DefView", vbNullString)
    hListView = FindWindowEx(hListView, 0, "SysListView32", vbNullString)
   
    '获取当前图标大小
    lStyle = GetWindowLong(hListView, GWL_STYLE)
    If lStyle And &H4000 Then
        iIconSize = 32
    Else
        iIconSize = 48
    End If
   
    '切换图标大小
    If iIconSize = 32 Then
        lResult = SendMessage(hListView, LVM_SETICONSPACING, 0, ByVal CLng(48 * 65536 + 48))
        SetWindowLong hListView, GWL_STYLE, lStyle And Not &H4000
    Else
        lResult = SendMessage(hListView, LVM_SETICONSPACING, 0, ByVal CLng(32 * 65536 + 32))
        SetWindowLong hListView, GWL_STYLE, lStyle Or &H4000
    End If
   
    '刷新桌面
    SendMessage hWnd, &H111, &HB, ByVal 0&
End Sub

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2023-03-27 18:42



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-504719-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.430709 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved