Locations of visitors to this page
Onteora Software - October 2005

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Find Missing dll

Find Missing dll



There was a question the other day in the vb.net newsgroup on how to make a list of the missing dlls on your system. Files that are registered by regsvr32 create a CLSID. This program will check all the CLSID registered dll exists and adds the missing ones to a list box.



Imports Microsoft.Win32
Imports System.IO

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    Friend WithEvents lstMissingDll As System.Windows.Forms.ListBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.lstMissingDll = New System.Windows.Forms.ListBox
        Me.SuspendLayout()
        '
        'lstMissingDll
        '
        Me.lstMissingDll.Location = New System.Drawing.Point(24, 24)
        Me.lstMissingDll.Name = "lstMissingDll"
        Me.lstMissingDll.Size = New System.Drawing.Size(680, 212)
        Me.lstMissingDll.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(736, 266)
        Me.Controls.Add(Me.lstMissingDll)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim rkCLSID As RegistryKey = Registry.ClassesRoot.OpenSubKey("CLSID")
        Dim strKey As String
        Dim strSys32 As String = Environment.GetFolderPath(Environment.SpecialFolder.System) & "\"

        For Each strKey In rkCLSID.GetSubKeyNames
            Try
                ' only check for dll name if it is a clsid
                If strKey.IndexOf("{") >= 0 Then
                    Dim strPath As String
                    Dim rk As RegistryKey = rkCLSID.OpenSubKey(strKey & "\InprocServer32")
                    Dim strDll As String = rk.GetValue("").ToString
                    If strDll.IndexOf("\") > 0 Then
                        'gave full path
                        strPath = strDll
                    Else
                        ' in system32 directory
                        strPath = strSys32 & strDll
                    End If
                    Dim str As String = """"
                    strPath = strPath.Replace(str, "")
                    Trace.WriteLine(strPath)
                    If Not File.Exists(strPath) Then
                        ' file doesnt exist add to listbox
                        lstMissingDll.Items.Add(strPath)
                    End If
                End If
            Catch
            End Try
        Next
    End Sub
End Class

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Archive
Posted by Ken Tucker on Sunday, October 02, 2005 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed