Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 27th, 2005, 07:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default Where are the GUIDS

Hi folks,

I'm working on some code that will check and see if a certain type library isn't referenced in an app. Not a broken reference, but a reference that has never been set in the app before.

I have the code working with the ADO library, just cause I happen to know what its GUID is.

How do I find the GUIDs (used by the registry) for other dlls I'm interested in. I've putz around in the registy's TypLib key which weems to be where they are stored. Can't determine with certainty, however, which dlls the GUIDs are associated with.

I'm particularly interested in the Microsoft OLE DB Service Component 1.0 Type Library, oledb32.dll. I know where it is, but I'm GUIDless. Any help on where to locate GUIDs or suggestions regarding this type of reference check routine would be much appreciated.

Thanks,

Bob

 
Old January 2nd, 2006, 05:25 AM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I'm working on references myself, so I found this line:

ThisWorkbook.VBProject.References.Item(youritem).G UID

This will return a 16-character string

 
Old January 2nd, 2006, 10:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Thanks a million,

I actually wanted this code to use in a VBA class module, and its working great.

I used the following to get the name and GUID of the "Microsoft OLE DB Service Component 1.0 Type Library":

Code:
Sub FindGuids()
   Dim ref As Access.Reference

   For Each ref In Application.References
      Debug.Print ref.Name & " - " & ref.Guid
   Next

End Sub
This output: MSDASC - {2206CEB0-19C1-11D1-89E0-00C04FD7A829}

Then I use the name and GUID in the Class_Initialize() event of a data access class to see if MSDASC is referenced like this:

Code:
Option Compare Database

Private m_intErrorHandling As Integer
Private Const ERR_BAD_MSDASC_REFERENCE = vbObjectError + 515

'=====================================================================
' Class_Initialize
' ----------------
' Checks for a valid reference to the MSDASC library and initializes
' property default values.
'=====================================================================
Private Sub Class_Initialize()

   On Error GoTo 0

   Dim ref As Access.Reference
   Dim blnMSDASCReferenced As Boolean, blnBroken As Boolean

   Const cMSDASCGUID As String = "{2206CEB0-19C1-11D1-89E0-00C04FD7A829}"

   m_intErrorHandling = Application.GetOption("Error Trapping")
   Application.SetOption "Error Trapping", 2

   For Each ref In Application.References
      On Error Resume Next
      blnBroken = ref.IsBroken
         If VBA.Err Then blnBroken = True
            On Error GoTo 0
            If ref.Name = "MSDASC" And ref.Kind = 0 And _
               VBA.StrComp(ref.Guid, cMSDASCGUID, 1) = 0 And _
               Not blnBroken Then
               blnMSDASCReferenced = True
            Exit For
         End If
   Next ref
      Set ref = Nothing

      If Not blnMSDASCReferenced Then _
         Err.Raise ERR_BAD_MSDASC_REFERENCE, "clsCursorAnalyzer::Initialize", _
            "A reference to MSDASC has to be set."

End Sub
Thanks again!

Bob







Similar Threads
Thread Thread Starter Forum Replies Last Post
Guids mlw C# 2008 aka C# 3.0 5 June 23rd, 2008 03:52 PM
How can I populate large table with unique Guids? ExDb BOOK: Beginning VB.NET Databases 9 August 23rd, 2007 04:18 AM
Discovering ProgId’s and/or GUIDs from unregistere jlick Pro VB 6 0 November 13th, 2003 01:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.