Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Register Control (vb6)

    Using RegSvr32.exe to register controls ie:

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



    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 ?

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Register Control (vb6)

    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

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Register Control (vb6)

    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"

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Register Control (vb6)

    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?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Register Control (vb6)

    Unless you have users with an OS older than Windows 95 SR2 or Windows NT4 SP5 and a browser older than Internet Explorer 3 <img src=/S/yikes.gif border=0 alt=yikes width=15 height=15>, they already have Regsvr32.exe on their PC's. No need to install it.

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Register Control (vb6)

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

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Register Control (vb6)

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

    <hr>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 /? <hr>
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •