Welcome, guest | Sign In | My Account | Store | Cart

Do you like Nir Sofer's MUICacheView tool? Why do you not write own? This sample correctly work on WinXP but there is no problem to edit it for Win7.

Text, 295 lines
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
import clr

clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")

from System import Array, Exception, Environment
from System.IO import Path, StreamWriter
from System.Text import Encoding
from System.Drawing import Font, FontStyle, Icon, Point, Size
from Microsoft.Win32 import Registry
from System.Windows.Forms import (
  Application, Button, ColumnHeader, Control, Form, FormBorderStyle,
  FormStartPosition, DockStyle, Label, ListView, MainMenu, MenuItem,
  MessageBox, MessageBoxButtons, MessageBoxIcon, PictureBox,
  PictureBoxSizeMode, Shortcut, SortOrder, StatusBar, View
)

class frmMain(Form):
   def __init__(self):
      self._key = r"Software\Microsoft\Windows\ShellNoRoam\MUICache"
      self._csv = Environment.CurrentDirectory + r"\MUICacheView.csv"
      self.InitializeComponent()

   def InitializeComponent(self):
      self._mnuMain = MainMenu()
      self._mnuFile = MenuItem()
      self._mnuScan = MenuItem()
      self._mnuSave = MenuItem()
      self._mnuNull = MenuItem()
      self._mnuExit = MenuItem()
      self._mnuEdit = MenuItem()
      self._mnuKill = MenuItem()
      self._mnuView = MenuItem()
      self._mnuHide = MenuItem()
      self._mnuSBar = MenuItem()
      self._mnuHelp = MenuItem()
      self._mnuInfo = MenuItem()
      self._lstView = ListView()
      self._chPath_ = ColumnHeader()
      self._chName_ = ColumnHeader()
      self._sbInfo_ = StatusBar()
      #
      #mnuMain
      #
      self._mnuMain.MenuItems.AddRange(Array[MenuItem]((self._mnuFile,
                        self._mnuEdit, self._mnuView, self._mnuHelp)))
      #
      #mnuFile
      #
      self._mnuFile.MenuItems.AddRange(Array[MenuItem]((self._mnuScan,
                        self._mnuSave, self._mnuNull, self._mnuExit)))
      self._mnuFile.Text = "&File"
      #
      #mnuScan
      #
      self._mnuScan.Shortcut = Shortcut.F5
      self._mnuScan.Text = "S&can"
      self._mnuScan.Click += self.mnuScan_Click
      #
      #mnuSave
      #
      self._mnuSave.Shortcut = Shortcut.CtrlS
      self._mnuSave.Text = "&Save log"
      self._mnuSave.Click += self.mnuSave_Click
      #
      #mnuNull
      #
      self._mnuNull.Text = "-"
      #
      #mnuExit
      #
      self._mnuExit.Shortcut = Shortcut.CtrlX
      self._mnuExit.Text = "E&xit"
      self._mnuExit.Click += self.mnuExit_Click
      #
      #mnuEdit
      #
      self._mnuEdit.MenuItems.Add(self._mnuKill)
      self._mnuEdit.Text = "&Edit"
      #
      #mnuKill
      #
      self._mnuKill.Shortcut = Shortcut.Del
      self._mnuKill.Text = "&Delete item"
      self._mnuKill.Click += self.mnuKill_Click
      #
      #mnuView
      #
      self._mnuView.MenuItems.AddRange(Array[MenuItem]((self._mnuHide, self._mnuSBar)))
      self._mnuView.Text = "&View"
      #
      #mnuHide
      #
      self._mnuHide.Checked = True
      self._mnuHide.Shortcut = Shortcut.CtrlH
      self._mnuHide.Text = "&Hide system entries"
      self._mnuHide.Click += self.mnuHide_Click
      #
      #mnuSBar
      #
      self._mnuSBar.Checked = True
      self._mnuSBar.Shortcut = Shortcut.CtrlB
      self._mnuSBar.Text = "Show Status &Bar"
      self._mnuSBar.Click += self.mnuSBar_Click
      #
      #mnuHelp
      #
      self._mnuHelp.MenuItems.Add(self._mnuInfo)
      self._mnuHelp.Text = "&Help"
      #
      #mnuInfo
      #
      self._mnuInfo.Text = "About"
      self._mnuInfo.Click += self.mnuInfo_Click
      #
      #lstView
      #
      self._lstView.AllowColumnReorder = True
      self._lstView.Columns.AddRange(Array[ColumnHeader]((self._chPath_, self._chName_)))
      self._lstView.Dock = DockStyle.Fill
      self._lstView.FullRowSelect = True
      self._lstView.GridLines = True
      self._lstView.MultiSelect = False
      self._lstView.Sorting = SortOrder.Ascending
      self._lstView.View = View.Details
      #
      #chPath_
      #
      self._chPath_.Text = "Application Path"
      self._chPath_.Width = 275
      #
      #chName_
      #
      self._chName_.Text = "Application Name"
      self._chName_.Width = 330
      #
      #sbInfo_
      #
      self._sbInfo_.SizingGrip = False
      #
      #frmMain
      #
      self.ClientSize = Size(573, 217)
      self.Controls.AddRange(Array[Control]((self._lstView, self._sbInfo_)))
      self.MaximizeBox = False
      self.Menu = self._mnuMain
      self.StartPosition = FormStartPosition.CenterScreen
      self.Text = "MUICacheView"
      self.Load += self.frmMain_Load

   """ count finded items """
   def ItemsCounting(self):
      self._sbInfo_.Text = self._lstView.Items.Count.ToString() + " item(s)"

   """ build items list """
   def BuildItemsList(self, node):
      rk = Registry.CurrentUser.OpenSubKey(self._key)

      self._item = self._lstView.Items.Add(node)
      self._item.SubItems.Add(rk.GetValue(node).ToString())

   """ looking for items """
   def InvokeScaning(self):
      self._lstView.Items.Clear()

      rk = Registry.CurrentUser.OpenSubKey(self._key)
      for name in rk.GetValueNames():
         if rk.GetValueKind(name).ToString() != "Binary":
            if self._mnuHide.Checked:
               if not name.StartsWith("@"):
                  self.BuildItemsList(name)
            else:
               self.BuildItemsList(name)

   """ loading main form """
   def frmMain_Load(self, sender, e):
      self.ItemsCounting()

   """ pushing 'Scan' button """
   def mnuScan_Click(self, sender, e):
      self.InvokeScaning()
      self.ItemsCounting()

   """ saving log """
   def mnuSave_Click(self, sender, e):
      if self._lstView.Items.Count != 0:
         sw = StreamWriter(self._csv, False, Encoding.Default)
         i = 0
         while i < self._lstView.Items.Count:
            j = 0
            while j < self._lstView.Columns.Count:
               res = self._lstView.Items[i].Text + ", " + self._lstView.Items[i].SubItems[j].Text
               j += 1
            sw.WriteLine(res)
            i += 1
         sw.Flush()
         sw.Close()

   """ closing """
   def mnuExit_Click(self, sender, e):
      Application.Exit()

   """ deleting item permanently """
   def mnuKill_Click(self, sender, e):
      rk = Registry.CurrentUser.OpenSubKey(self._key, True)
      i = 0
      while i < self._lstView.Items.Count:
         if self._lstView.Items[i].Selected:
            rk.DeleteValue(self._lstView.Items[i].Text, False)
            self._lstView.Items[i].Remove()
            i -= 1
         i += 1

      self.ItemsCounting()

   """ toggle of system entries """
   def mnuHide_Click(self, sender, e):
      toggle = not self._mnuHide.Checked
      self._mnuHide.Checked = toggle

      self.InvokeScaning()
      self.ItemsCounting()

   """ toggle of status bar """
   def mnuSBar_Click(self, sender, e):
      toggle = not self._mnuSBar.Checked
      self._mnuSBar.Checked = toggle
      self._sbInfo_.Visible = toggle

   """ copyright info """
   def mnuInfo_Click(self, sender, e):
      frm = frmAbout()
      frm.ShowDialog(self)



class frmAbout(Form):
   def __init__(self):
      self.InitializeComponent()

   def InitializeComponent(self):
      self._pbImage = PictureBox()
      self._lblName = Label()
      self._lblCopy = Label()
      self._btnExit = Button()
      #
      #pbImage
      #
      self._pbImage.Location = Point(16, 16)
      self._pbImage.Size = Size(32, 32)
      self._pbImage.SizeMode = PictureBoxSizeMode.StretchImage
      #
      #lblName
      #
      self._lblName.Font = Font("Microsoft Sans Serif", 9, FontStyle.Bold)
      self._lblName.Location = Point(53, 19)
      self._lblName.Size = Size(360, 18)
      self._lblName.Text = "MUICacheView v1.00"
      #
      #lblCopy
      #
      self._lblCopy.Location = Point(67, 37)
      self._lblCopy.Size = Size(360, 23)
      self._lblCopy.Text = "(C) 2012 Greg Zakharov gregzakh@gmail.com"
      #
      #btnExit
      #
      self._btnExit.Location = Point(135, 67)
      self._btnExit.Text = "OK"
      #
      #frmAbout
      #
      self.AcceptButton = self._btnExit
      self.CancelButton = self._btnExit
      self.ClientSize = Size(350, 110)
      self.ControlBox = False
      self.Controls.AddRange(Array[Control]((self._pbImage,
             self._lblName, self._lblCopy, self._btnExit)))
      self.FormBorderStyle = FormBorderStyle.FixedSingle
      self.ShowInTaskbar = False
      self.StartPosition = FormStartPosition.CenterParent
      self.Text = "About..."
      self.Load += self.frmAbout_Load

   def frmAbout_Load(self, sender, e):
      try:
        self._pbImage.Image = self.Owner.Icon.ToBitmap()
      except Exception, e:
        MessageBox.Show(e.Message, self.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop)



if __name__ == "__main__":
   Application.EnableVisualStyles()
   Application.Run(frmMain())
Created by greg zakharov on Mon, 18 Feb 2013 (MIT)
Text recipes (14)
greg zakharov's recipes (59)

Required Modules

  • (none specified)

Other Information and Tasks