• Register Control (vb6)

    Author
    Topic
    #401073

    Using RegSvr32.exe to register controls ie:

    Shell ("L:mmpdfutilitiesregsvr32.exe /s msmapi32.ocx")

    How do I determine where to register to, C:WindowsSystem for older Operating systems or C:WindowsSystem32 on newer systems.

    Do I check with the DIR command to see if the folders exist, or does RegSvr32.exe already determine this ?

    Viewing 3 reply threads
    Author
    Replies
    • #787211

      Recommend use Windows GetSystemDirectory API function. Example:

      Private Declare Function GetSystemDirectory Lib “kernel32” _
      Alias “GetSystemDirectoryA” (ByVal lpBuffer As String, _
      ByVal nSize As Long) As Long
      Const MAX_PATH = 260

      Public Function GetSystemDirectoryAPI() As String

      Dim strFolder As String
      Dim lngResult As Long

      strFolder = String$(MAX_PATH, 0)
      lngResult = GetSystemDirectory(strFolder, MAX_PATH)

      If lngResult 0 Then
      GetSystemDirectoryAPI = Left$(strFolder, InStr(strFolder, Chr$(0)) – 1)
      Else
      GetSystemDirectoryAPI = vbNullString
      End If

      End Function

      Example, on WIN 2K system:

      ? GetSystemDirectoryAPI
      C:WINNTsystem32

      This should work on any Windows 95/98/NT or later system.

      HTH

    • #787212

      Recommend use Windows GetSystemDirectory API function. Example:

      Private Declare Function GetSystemDirectory Lib “kernel32” _
      Alias “GetSystemDirectoryA” (ByVal lpBuffer As String, _
      ByVal nSize As Long) As Long
      Const MAX_PATH = 260

      Public Function GetSystemDirectoryAPI() As String

      Dim strFolder As String
      Dim lngResult As Long

      strFolder = String$(MAX_PATH, 0)
      lngResult = GetSystemDirectory(strFolder, MAX_PATH)

      If lngResult 0 Then
      GetSystemDirectoryAPI = Left$(strFolder, InStr(strFolder, Chr$(0)) – 1)
      Else
      GetSystemDirectoryAPI = vbNullString
      End If

      End Function

      Example, on WIN 2K system:

      ? GetSystemDirectoryAPI
      C:WINNTsystem32

      This should work on any Windows 95/98/NT or later system.

      HTH

    • #787215

      Regsvr32 uses the search path; this usually starts with the system folder, whatever it is called. So you don’t need to worry about specifying C:WindowsSystem32 or C:WindowsSystem or C:WinNTSystem32. You also shouldn’t have to specify the path for Regsvr32, it ought to be present in the system folder, and therefore be found automatically. So the following should be sufficient:

      Shell “regsvr32.exe /s msmapi32.ocx”

      • #787217

        Hans
        I use the L:….RegSvr…….. because it is copied on first installation.
        When a user uses my application for the first time, the splash form creates certain folders and copies certain utilities
        such as edjpjcom.exe. msmapi32.ocx, help files etc into L:MMPDFUtilities

        Although it does work, I was concerned whether I was registering to the wrong directory..

        Mark, As above, it works ok, would I improve anything or erradicate future problems by implementing your code?

        • #787227

          Unless you have users with an OS older than Windows 95 SR2 or Windows NT4 SP5 and a browser older than Internet Explorer 3 yikes, they already have Regsvr32.exe on their PC’s. No need to install it.

          • #787231

            I didn’t realise that, now I know, I can probably cut the code a little then.
            Thanks again.

          • #787232

            I didn’t realise that, now I know, I can probably cut the code a little then.
            Thanks again.

        • #787228

          Unless you have users with an OS older than Windows 95 SR2 or Windows NT4 SP5 and a browser older than Internet Explorer 3 yikes, they already have Regsvr32.exe on their PC’s. No need to install it.

        • #787241

          If you look at some examples of using REGSVR32.EXE provided by MS, some specify path, some do not. Excerpt from MSKB 198038:

          [indent]


          Regsvr32.exe
          Regsvr32.exe allows you to register/un-register DLL and OCX files that are self-registerable. Regsvr32.exe provides rudimentary error codes as well as a silent install option.

          Regsvr32.exe is installed with Microsoft Visual Basic and can be found in the System (or System32) directory.

          When used, Regsvr32.exe attempts to load the component and call it’s DLLSelfRegister function. If successful Regsvr32.exe displays a dialog indicating success. If the registration fails, Regsvr32.exe returns a basic error code.

          To use the Regsvr32.exe utility to register a component perform the following steps:
          Open an MS-DOS Command prompt or from the Windows Start menu, select Run.
          Execute the following command line:
          REGSVR32.EXE C:WINDOWSSYSTEMCOMPONENT.DLL

          Component.dll is the DLL/OCX to register onto the system. The path to the component must be included in the command line.

          Components can be unregistered using the /u command line parameter.
          For additional information on Regsvr32.exe command line parameters, execute the following command from an MS-DOS command line:
          REGSVR32.EXE /?


          [/indent]
          Contrary to above, other MS examples show path to component NOT necessary, as long as the component & Regsvr32.exe are located in same folder. So if the component being registered is already located in the System/System32 folder, it should not be necessary to specify full path; path would be needed only if located in non-system folder. If your program needs to copy the component to the target pc’s System folder, then the API function would be useful to ensure you are copying the component to the correct location.

          HTH

        • #787242

          If you look at some examples of using REGSVR32.EXE provided by MS, some specify path, some do not. Excerpt from MSKB 198038:

          [indent]


          Regsvr32.exe
          Regsvr32.exe allows you to register/un-register DLL and OCX files that are self-registerable. Regsvr32.exe provides rudimentary error codes as well as a silent install option.

          Regsvr32.exe is installed with Microsoft Visual Basic and can be found in the System (or System32) directory.

          When used, Regsvr32.exe attempts to load the component and call it’s DLLSelfRegister function. If successful Regsvr32.exe displays a dialog indicating success. If the registration fails, Regsvr32.exe returns a basic error code.

          To use the Regsvr32.exe utility to register a component perform the following steps:
          Open an MS-DOS Command prompt or from the Windows Start menu, select Run.
          Execute the following command line:
          REGSVR32.EXE C:WINDOWSSYSTEMCOMPONENT.DLL

          Component.dll is the DLL/OCX to register onto the system. The path to the component must be included in the command line.

          Components can be unregistered using the /u command line parameter.
          For additional information on Regsvr32.exe command line parameters, execute the following command from an MS-DOS command line:
          REGSVR32.EXE /?


          [/indent]
          Contrary to above, other MS examples show path to component NOT necessary, as long as the component & Regsvr32.exe are located in same folder. So if the component being registered is already located in the System/System32 folder, it should not be necessary to specify full path; path would be needed only if located in non-system folder. If your program needs to copy the component to the target pc’s System folder, then the API function would be useful to ensure you are copying the component to the correct location.

          HTH

      • #787218

        Hans
        I use the L:….RegSvr…….. because it is copied on first installation.
        When a user uses my application for the first time, the splash form creates certain folders and copies certain utilities
        such as edjpjcom.exe. msmapi32.ocx, help files etc into L:MMPDFUtilities

        Although it does work, I was concerned whether I was registering to the wrong directory..

        Mark, As above, it works ok, would I improve anything or erradicate future problems by implementing your code?

    • #787216

      Regsvr32 uses the search path; this usually starts with the system folder, whatever it is called. So you don’t need to worry about specifying C:WindowsSystem32 or C:WindowsSystem or C:WinNTSystem32. You also shouldn’t have to specify the path for Regsvr32, it ought to be present in the system folder, and therefore be found automatically. So the following should be sufficient:

      Shell “regsvr32.exe /s msmapi32.ocx”

    Viewing 3 reply threads
    Reply To: Register Control (vb6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: