Check for missing dll's

  • Thread starter Thread starter DazedAndConfused
  • Start date Start date
D

DazedAndConfused

How would you check in an application for missing dll's so that the
application would inform the user what is wrong?
 
Hi,

When you regsvr a file it creates a clsid. This will get the
dll names from the registry. It will add any dll that it cant find to a
listbox lstMissingDll


Imports Microsoft.Win32
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

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


Ken
 
Nice bit of code Ken


Ken Tucker said:
Hi,

When you regsvr a file it creates a clsid. This will get the
dll names from the registry. It will add any dll that it cant find to a
listbox lstMissingDll


Imports Microsoft.Win32
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

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


Ken
 
Wow, that gets ALL missing DLL's, thank you.
Ken Tucker said:
Hi,

When you regsvr a file it creates a clsid. This will get the
dll names from the registry. It will add any dll that it cant find to a
listbox lstMissingDll


Imports Microsoft.Win32
Imports System.IO

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

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


Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top