🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.lang.visualbasic.ver3
1 messages
1 total messages Started by ARJEN Sat, 10 Nov 2001 15:40
HELP: Can't get CLSID / GUID (classID) from ActiveX DLL or OCX
#23
Author: ARJEN
Date: Sat, 10 Nov 2001 15:40
81 lines
4194 bytes
I've tried to extract the CLSID / GUID from an OCX or DLL file using the
code from
http://support.microsoft.com/support/kb/articles/q174/0/50.asp?FR=0
and using GetClsidFromActXFile API from the VB5STKIT.DLL and VB6STKIT.DLL.
The function GetClassID in the following code however returs
"{00000000-0000-0000-0000-000000000000}" for every file and
GetClsidFromActXFile returns an empty string. What am I doing wrong? Please
Help!!

Option Explicit

  Type GUID
    B(16) As Byte
  End Type

  Declare Function GetClassFile _
    Lib "Ole32.DLL" _
    (ByVal lpszFileName As String, _
    ByRef pclsid As GUID) As Long

  Declare Function StringFromGUID2 _
    Lib "Ole32.DLL" _
    (ByRef rguid As GUID, _
    ByVal lpsz As String, _
    ByVal cbMax As Long) As Long

  Public Declare Function GetCLSID5 _
    Lib "VB5STKIT.DLL" _
    Alias "GetClsidFromActXFile" _
    (ByVal pszFilename As String, _
    ByVal pszProgID As String, _
    ByVal pszClsid As String) As Long

  Public Declare Function GetCLSID6 _
    Lib "VB6STKIT.DLL" _
    Alias "GetClsidFromActXFile" _
    (ByVal pszFilename As String, _
    ByVal pszProgID As String, _
    ByVal pszClsid As String) As Long

Sub MAIN()

  Const PeekInDir = "c:\windows\desktop\x\"

  Dim MyCLSID As String
  Dim MyProgID As String
  Dim RetVal As Long
  Dim ThisFile As Variant
  Dim AllFiles As New Collection

  ThisFile = Dir(PeekInDir & "*.*")  ' They are all DLL and OCX files in
this dir.
  While Not ThisFile = vbNullString
    AllFiles.Add ThisFile
    ThisFile = Dir
  Wend

  For Each ThisFile In AllFiles
    MyCLSID = GetCLSID(PeekInDir & CStr(ThisFile))
    Debug.Print ThisFile & ": ", MyCLSID, "|";
    RetVal = GetCLSID5(PeekInDir & CStr(ThisFile), MyProgID, MyCLSID)
    Debug.Print RetVal, MyProgID, MyCLSID, "|";
    RetVal = GetCLSID6(PeekInDir & CStr(ThisFile), MyProgID, MyCLSID)
    Debug.Print RetVal, MyProgID, MyCLSID, "|"
  Next
End Sub

Function GetCLSID(FileName As String) As String
  Dim g As GUID
  Dim RetVal As Long
  Dim strGUID As String

  RetVal = GetClassFile(StrConv(FileName, vbUnicode), g)
  strGUID = Space(255)
  RetVal = StringFromGUID2(g, strGUID, 255)
  strGUID = StrConv(strGUID, vbFromUnicode)
  If (InStr(strGUID, Chr(0)) > 0) Then
     strGUID = Left(strGUID, InStr(strGUID, Chr(0)) - 1)
  End If
  GetCLSID = strGUID
End Function
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads