デスクトップを[詳細]表示にする

Excelがある環境下で動くVBScript。SetWindowLongAに渡す値を調整すれば[一覧]などにもできます。

Option Explicit

Dim Excel
Set Excel = CreateObject("Excel.Application")

Dim hWnd
hWnd = Excel.ExecuteExcel4Macro("CALL(""user32"",""FindWindowA"",  ""JCC"",  ""Progman"",""Program Manager"")")
hWnd = Excel.ExecuteExcel4Macro("CALL(""user32"",""FindWindowExA"",""JJJCJ""," & hWnd & ",0,""SHELLDLL_DefView"",0)")
hWnd = Excel.ExecuteExcel4Macro("CALL(""user32"",""FindWindowExA"",""JJJCJ""," & hWnd & ",0,""SysListView32"",   0)")
If hWnd Then
  const GWL_STYLE     = -16
  Dim style
  style = Excel.ExecuteExcel4Macro("CALL(""user32"",""GetWindowLongA"",""JJJ""," & hWnd & "," & GWL_STYLE & ")")

  ' 表示設定を変更
  ' http://yokohama.cool.ne.jp/chokuto/urawaza/prm/comctl_style.html
  const LVS_REPORT    = &H1
  const LVS_SMALLICON = &H2
  const LVS_LIST      = &H3
  If style and LVS_REPORT Then
    style = style xor LVS_REPORT
  Else
    style = style  or LVS_REPORT
  End If

  ' スクロールしない設定であればそれを解除
  const LVS_NOSCROLL       = &H2000
  If style and LVS_NOSCROLL Then
    style = style xor LVS_NOSCROLL
  End If

  ' ヘッダを表示しない設定であればそれを解除
  const LVS_NOCOLUMNHEADER = &H4000
  If style and LVS_NOCOLUMNHEADER Then
    style = style xor LVS_NOCOLUMNHEADER
  End If

  Excel.ExecuteExcel4Macro("CALL(""user32"",""SetWindowLongA"",""JJJJ""," & hWnd & "," & GWL_STYLE & "," & style & ")")
End If

XPだと綺麗に表示されますが、Vistaだとなぜかこんな感じに黒塗りになってしまいます。カコワルイ。

ちなみに、職場のXPに適用して「我ながらこれはすばらしい!」と言ったら「君のセンスはわからん」と返されました。