Article View: alt.comp.lang.visualbasic.ver3
Article #23HELP: Can't get CLSID / GUID (classID) from ActiveX DLL or OCX
From: ARJEN
Date: Sat, 10 Nov 2001 15:40
Date: Sat, 10 Nov 2001 15:40
81 lines
4194 bytes
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
Technical Details
Message-ID:
<1005406840.493114@news.knoware.nl>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!news2.news.support.nl!News-Service!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c949,6845efa3c80a2c8e,start X-Google-Attributes: gid10c949,public X-Google-Thread: 110e3b,6845efa3c80a2c8e,start X-Google-Attributes: gid110e3b,public X-Google-Thread: fb992,6845efa3c80a2c8e,start X-Google-Attributes: gidfb992,public X-Google-Thread: 1143a7,6845efa3c80a2c8e,start X-Google-Attributes: gid1143a7,public X-Google-Thread: f645d,6845efa3c80a2c8e,start X-Google-Attributes: gidf645d,public X-Google-Thread: 1023e1,6845efa3c80a2c8e,start X-Google-Attributes: gid1023e1,public X-Google-Thread: f5f6f,6845efa3c80a2c8e,start X-Google-Attributes: gidf5f6f,public X-Google-Thread: f8386,6845efa3c80a2c8e,start X-Google-Attributes: gidf8386,public X-Google-ArrivalTime: 2001-11-10 07:57:00 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!news2.news.support.nl!News-Service!not-for-mail From: "ARJEN" <nospam@nospam.com> Newsgroups: alt.comp.lang.visualbasic.ver3,basicworld.public.vb.winapi,comp.lang.basic.misc,comp.lang.basic.visual,comp.lang.basic.visual.3rdparty,comp.lang.basic.visual.database,comp.lang.basic.visual.misc,comp.lang.visual.basic,es.comp.lenguajes.visual-basi Subject: HELP: Can't get CLSID / GUID (classID) from ActiveX DLL or OCX Date: Sat, 10 Nov 2001 16:40:38 +0100 Organization: Knoware Lines: 84 Message-ID: <1005406840.493114@news.knoware.nl> NNTP-Posting-Host: 195.114.230.34 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Cache-Post-Path: news.knoware.nl!unknown@213.227.128.222 X-Cache: nntpcache 2.4.0b2 (see http://www.nntpcache.org/) Cache-Post-Path: cache.news.support.nl!unknown@news.knoware.nl