我是靠谱客的博主 落寞蜻蜓,最近开发中收集的这篇文章主要介绍(ZT)clear icon cache,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

前言

在玩一个cm.
cm有更换exe图标的行为, 如果不是cm, 有谁会搞这么扎眼的行为, 生怕别人不知道:)
在修改了注册表中HKEY_CLASSES_ROOTexefileDefaultIcon值为%1后, 需要刷新系统图标.
在网上找到一个人家写好的vbs, 在winxpsp3下试了好使. 用编程实现可以借鉴这个vbs, 也可以从cm中直接扒出刷新系统图标的实现.

正确的注册表导出

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOTexefileDefaultIcon]
@="%1"

cleariconcache.vbs

'(c) 2016 Ramesh Srinivasan.
'Clears the Icon Cache databases to lets Windows rebuild them fresh.
'for Windows Vista, 7, 8 and Windows 10.
'Written on Jan 31 2016
'Updated on Apr 01 2016
'http://www.winhelponline.com/blog

Option Explicit
Dim WshShell, objFSO, strICPath1, strICPath2, strmsg, rtnStatus, Process, iDirtyFlags, iDirtyFlags2
Const DeleteReadOnly = True
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strICPath1 = WshShell.ExpandEnvironmentStrings("%LOCALAPPDATA%")
strICPath2 = strICPath1 & "MicrosoftWindowsExplorer"

ExitExplorerShell
WScript.Sleep(3000)
ClearIconCache
WScript.Sleep(2000)
StartExplorerShell

Sub ExitExplorerShell()
    strmsg = "Explorer Shell will be terminated now."
    strmsg = strmsg & " Please save all your work and close all programs."
    strmsg = strmsg & "Icon cache may not be cleared if programs are using them. Want to continue?"
    rtnStatus = MsgBox (strmsg, vbYesNo, "Clear the Icon Cache")
    If rtnStatus = vbYes Then
        For Each Process in GetObject("winmgmts:"). _
            ExecQuery ("select * from Win32_Process where name='explorer.exe'")
            Process.terminate(1)
        Next
    ElseIf rtnStatus = vbNo Then
        WScript.Quit
    End If
End Sub

Sub StartExplorerShell
    WshShell.Run "explorer.exe"
End Sub

Sub ClearIconCache()
    If (objFSO.FileExists(strICPath1 &"IconCache.db")) Then
    On Error Resume Next
        objFSO.DeleteFile strICPath1 &"IconCache.db", DeleteReadOnly
    On Error Goto 0
        If Err.Number <> 0 AND Err.Number <> 53 Then
            iDirtyFlags = 1
        End If
    End If

    If objFSO.FolderExists(strICPath2) Then
    On Error Resume Next
        objFSO.DeleteFile(strICPath2 & "icon*.db"), DeleteReadOnly
    On Error Goto 0
        If Err.Number <> 0 AND Err.Number <> 53 Then
            iDirtyFlags2 = 1
        End If      
    End If

    WshShell.Run "ie4uinit.exe -ClearIconCache"
    WshShell.Run "ie4uinit.exe -show"
End Sub

If iDirtyFlags = 1 Then
    rtnStatus = MsgBox ("Some programs are still using the IconCache.db in LOCALAPPDATA. Close all programs and try again", vbOKonly, "Clear the Icon Cache")
End If

If iDirtyFlags2 = 1 Then
    If iDirtyFlags <> 1  Then
        rtnStatus = MsgBox ("Some programs are still using the cache in Location 2. Close all programs and try again", vbOKOnly, "Clear the Icon Cache")
    End If
End If

If iDirtyFlags = 0 And iDirtyFlags2 = 0 Then
    MsgBox "Successfully cleared the Icon Caches.", vbOKOnly, "Clear the Icon Cache"
End If

Set WshShell = Nothing
Set objFSO = Nothing

最后

以上就是落寞蜻蜓为你收集整理的(ZT)clear icon cache的全部内容,希望文章能够帮你解决(ZT)clear icon cache所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部