|
-
Feb 26th, 2010, 01:02 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Determine if ocx is registered
I have very through error checking in my app., but sometimes i get reports
that my app will not run, with an error message:
"missing components after deployment'". So my does not even start. my plan is to create a exe that will check for all the files my app installs and will tell me if the ocx's are registered. How to determine if an ocx is registered ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 26th, 2010, 01:06 PM
#2
Re: Determine if ocx is registered
Use Createobject to create an instance of it (with an error handler), if there is no error then it is installed (so destroy your instance).
-
Feb 26th, 2010, 01:13 PM
#3
Thread Starter
PowerPoster
Re: Determine if ocx is registered
 Originally Posted by si_the_geek
Use Createobject to create an instance of it (with an error handler), if there is no error then it is installed (so destroy your instance).
Would i not have to try to use it to determine if registered ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 26th, 2010, 01:20 PM
#4
Re: Determine if ocx is registered
One more way...
When you open the OCX with OleView.exe, you will see a UUID. Check in registry if this exists
HKCR\CLSID\{uuid}
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 26th, 2010, 01:26 PM
#5
Re: Determine if ocx is registered
 Originally Posted by isnoend07
Would i not have to try to use it to determine if registered ?
No, if the class you requested is not available (ie: it is not registered) then CreateObject will fail.
-
Feb 26th, 2010, 01:35 PM
#6
Thread Starter
PowerPoster
Re: Determine if ocx is registered
 Originally Posted by koolsid
One more way...
When you open the OCX with OleView.exe, you will see a UUID. Check in registry if this exists
HKCR\CLSID\{uuid}
what is OleView.exe ? Don't want to add another exe
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 26th, 2010, 01:48 PM
#7
Re: Determine if ocx is registered
Not sure how well this works but seen it used to determine if a DLL is registered, seems to work for OCX as well...
Code:
Option Explicit
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Sub Form_Click()
If IsDLLAvailable("TABCTL32.OCX") Then
MsgBox "DLL or OCX passed!"
Else
MsgBox "DLL or OCX Failed!"
' MsgBox ApiErrorText(Err.LastDllError)
' for ApiErrorText, see: http://www.mvps.org/vb/index2.html?tips/formatmessage.htm
End If
End Sub
Function IsDLLAvailable(ByVal DllFilename As String) As Boolean
Dim hModule As Long
' attempt to load the module
hModule = LoadLibrary(DllFilename)
If hModule > 32 Then
FreeLibrary hModule ' decrement the DLL usage counter
IsDLLAvailable = True
End If
End Function
-
Feb 26th, 2010, 02:18 PM
#8
Thread Starter
PowerPoster
Re: Determine if ocx is registered
 Originally Posted by Edgemeal
Not sure how well this works but seen it used to determine if a DLL is registered, seems to work for OCX as well...
Code:
Option Explicit
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Sub Form_Click()
If IsDLLAvailable("TABCTL32.OCX") Then
MsgBox "DLL or OCX passed!"
Else
MsgBox "DLL or OCX Failed!"
' MsgBox ApiErrorText(Err.LastDllError)
' for ApiErrorText, see: http://www.mvps.org/vb/index2.html?tips/formatmessage.htm
End If
End Sub
Function IsDLLAvailable(ByVal DllFilename As String) As Boolean
Dim hModule As Long
' attempt to load the module
hModule = LoadLibrary(DllFilename)
If hModule > 32 Then
FreeLibrary hModule ' decrement the DLL usage counter
IsDLLAvailable = True
End If
End Function
thanks for adding that, upon testing a ocx i have it reports: MsgBox "DLL or OCX passed!" even after i unregister it
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 26th, 2010, 02:25 PM
#9
Re: Determine if ocx is registered
 Originally Posted by isnoend07
thanks for adding that, upon testing a ocx i have it reports: MsgBox "DLL or OCX passed!" even after i unregister it
Oh well that sucks, sorry if i wasted your time.
-
Feb 26th, 2010, 02:28 PM
#10
Thread Starter
PowerPoster
Re: Determine if ocx is registered
 Originally Posted by Edgemeal
Oh well that sucks, sorry if i wasted your time.
No problem. thanks for adding that
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 26th, 2010, 02:39 PM
#11
Re: Determine if ocx is registered
OleView.exe is used to find the uuid. It's not to be integrated... anyways
See if this helps you...
http://www.vbforums.com/showthread.php?t=544424
or this
http://www.foxite.com/archives/find-...0000078365.htm
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 26th, 2010, 05:49 PM
#12
Thread Starter
PowerPoster
Re: Determine if ocx is registered
most of the examples i have found want to register the ocx which i do not want as this would require admin privileges. looks like the best way is to check if it exists and do as si_the_geek suggested and try to use one of it's methods or properties and trap the error. I have a suspicion that the error is so seldom that it occurs because the user has copied the exe to another PC without running the setup.
Last edited by isnoend07; Feb 26th, 2010 at 05:51 PM.
Reason: more to add
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 27th, 2010, 05:13 AM
#13
Re: Determine if ocx is registered
 Originally Posted by isnoend07
as si_the_geek suggested and try to use one of it's methods or properties and trap the error.
That is not what I suggested, in fact I explicitly said you do not need to do that - all you need to do is try to create an instance.
If it isn't registered, that part is guaranteed to fail.
Adding more to the process just adds room for mistakes in your code, and takes more time to do so.
-
Feb 27th, 2010, 11:25 PM
#14
Thread Starter
PowerPoster
Re: Determine if ocx is registered
 Originally Posted by si_the_geek
That is not what I suggested, in fact I explicitly said you do not need to do that - all you need to do is try to create an instance.
If it isn't registered, that part is guaranteed to fail.
Adding more to the process just adds room for mistakes in your code, and takes more time to do so.
thanks for adding that, never realized it was so difficult to declare some objects. eg; 'get object's class name.
Code:
Private Sub Form_Load()
'include a reference to "TypeLib Information" (Project -> References...")
Dim t As TypeLibInfo
Set t = TLI.TypeLibInfoFromFile("CommComponent.OCX")
MsgBox t.Guid & vbCrLf & t.Name
Dim s As SearchItem
For Each s In t.GetTypes
MsgBox t.Name & "." & s.Name
Next
End Sub
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 28th, 2010, 04:26 AM
#15
Re: [RESOLVED] Determine if ocx is registered
You can easily find the class name in your original project, by using the full data type name for one of the creatable objects.
For example, with ADO code you have Recordset objects, and a declaration with the full data type name is like this:
Code:
Dim objRS as ADODB.Recordset
The library (the ADODB part) is listed at the top of the Object Browser.
..so for your program doing the testing, you would use something like this:
Code:
Set objTest = CreateObject("ADODB.Recordset")
You almost certainly only need to check one object per library.
-
Jul 7th, 2017, 07:53 PM
#16
Frenzied Member
Re: Determine if ocx is registered
 Originally Posted by isnoend07
thanks for adding that, never realized it was so difficult to declare some objects. eg; 'get object's class name.
Code:
Private Sub Form_Load()
'include a reference to "TypeLib Information" (Project -> References...")
Dim t As TypeLibInfo
Set t = TLI.TypeLibInfoFromFile("CommComponent.OCX")
MsgBox t.Guid & vbCrLf & t.Name
Debug.Print t.Guid
End Sub
This trick is useful when compatibility of ocx was broken during ActiveX development time. Once we know the GUID then we can modify the vbp file to supply right GUID.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|