Results 1 to 7 of 7

Thread: how to find loaded dll path in VB6.0

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2013
    Posts
    21

    how to find loaded dll path in VB6.0

    Hi All,

    I have a scenario where i'm using .net dll in VB6.0 application. I need to verify the .net dll location before using in VB6.0 to make sure that it is correct dll. so how to find the location("C:\Windows\Microsoft.NET\assembly\GAC_32\Test\v....") of dll using dll name(Test.dll). Thanks in advance
    Last edited by VB Developer; Apr 18th, 2014 at 03:01 AM.

  2. #2
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: how to find loaded dll path in VB6.0

    If the path is always the same but only the drive letter changes, then you could get the pc's main drive letter and just add the rest hard coded. If that is not the case, you can search pc (which could take a short to long time).

    This searches for the first found file.

    Code:
    Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal RootPath As String, ByVal InputPathName As String, ByVal OutputPathBuffer As String) As Long
    
    Private Function FindFile(FileName As String) As String
    Const BufferLen As Long = 260
    Dim sBuffer As String
    Dim lRet As Long
    Dim SystemDrive As String
    
      sBuffer = String(BufferLen, 0)
      SystemDrive = Environ("SystemDrive") & "\"
      
      lRet = SearchTreeForFile(SystemDrive, FileName, sBuffer)
      If lRet <> 0 Then FindFile = Left(sBuffer, InStr(1, sBuffer, Chr(0)) - 1)
    End Function
    
    Private Sub Command1_Click()
    MsgBox FindFile("Test.dll")
    End Sub

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: how to find loaded dll path in VB6.0

    I'm not sure why you would need it... the .NET DLL should be COM-visible, and thusly registered in the registry, so it shouldn't matter where it is.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2013
    Posts
    21

    Re: how to find loaded dll path in VB6.0

    I'm looking for this because need check the digital certificate of .net dll to make sure that .net dll is not replaced.

  5. #5
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,710

    Re: how to find loaded dll path in VB6.0

    I'm still not clear on whether the DLL is always in that directory or might be installed elsewhere. If it never moves, you can just use PathFileExists API call.

    If it's always in the same subdirectory from the Windows directory, Environ("WINDIR") & "\Microsoft.Net\" ...

    Or start a search from there using the search code someone posted above.

  6. #6
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    764

    Re: how to find loaded dll path in VB6.0

    As techgnome said, you should be using COM-visible .Net assemblies so the only way you're going to find them is through the Registry. Your .Net project should explicitly specify all the GUIDs and Type Library IIDs that it exposes (if it doesn't, change it to do so).

    Search the Registry under HKEY_CLASSES_ROOT\Typelib for the assembly's IID and version, then continue on down through LocaleId to the win32 subkey; the default value of this is the location of the .Net Assembly.

    Here's an example from Microsoft's own stable, the Primary InterOp assembly for ADO 2 (on a 32-bit system; Wow64 makes life even more "interesting"):
    Code:
    HKEY_CLASSES_ROOT\
       {00000200-0000-0010-8000-00AA006D2EA4}\   (Interface ID)
          2.0\                                   (Version) 
             0\                                  (Locale) 
                win32\
                   @ = "%CommonProgramFiles%\System\ado\msado20.tlb"
    Regards, Phill W.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Oct 2013
    Posts
    21

    Re: how to find loaded dll path in VB6.0

    after long time, started resuming this further

    Path of dll is decided by customer during installation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width