and if you dont even need to see if it is in the registry first ..
just check the system directory, if not there copy the ocx,
then register it with regsvr.

VB Code:
  1. '// TEST BUTTON
  2. Private Sub Command1_Click()
  3.     If Register("Msflxgrd.ocx") Then
  4.         Debug.Print "Registered Successfully"
  5.     Else
  6.         Debug.Print "Error Registering"
  7.     End If
  8. End Sub
  9.  
  10. '// REGISTER OCX FILE
  11. Public Function Register(ByVal FILEX As String) As Boolean
  12.     Dim RegOcx As String
  13.     Dim TmpOcx As String
  14. On Error GoTo Error_Handler:
  15.     'CHECK CLSID & FILE VALUES
  16.     If Right(LCase(FILEX), 4) = ".ocx" Then
  17.         RegOcx = SystemDirectory & "\" & FILEX
  18.         TmpOcx = App.Path & "\" & FILEX
  19.         'IF NOT IN SYSTEM DIRECTORY COPY
  20.         If LenB(Dir$(RegOcx)) = 0 Then
  21.             'IF TMP OCX EXISTS
  22.             If LenB(Dir$(TmpOcx)) > 0 Then
  23.                 FileCopy TmpOcx, RegOcx
  24.             Else
  25.             'CANT COPY SO EXIT
  26.                 Exit Function
  27.             End If
  28.         End If
  29.         'IF IN SYSTEM DIRECTORY NOW
  30.         If LenB(Dir$(RegOcx)) > 0 Then
  31.             Shell "regsvr32 -s " & RegOcx
  32.         Else
  33.         'CANT REG SO EXIT
  34.             Exit Function
  35.         End If
  36.         Register = True
  37.     End If
  38.     Exit Function
  39. Error_Handler:
  40.     Register = False
  41. End Function
  42.  
  43. '// GET WINDOWS SYSTEM DIRECTORY
  44. Private Function SystemDirectory()
  45.     Dim objFso As Object
  46.     Set objFso = CreateObject("scripting.filesystemobject")
  47.     SystemDirectory = objFso.GetSpecialFolder(1)
  48. End Function