John Skolits
askolits at ot.com
Wed Oct 22 20:57:08 CDT 2003
I like that "You da man thing"
Thanks. Makes it all worthwhile when someone appreciates a helping hand.
John
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Darren DICK
Sent: Wednesday, October 22, 2003 10:55 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] A2K: Regsvr32 assistance please
John
You da man!!!
This is absolutely perfect. This has been an area I have been putting off
for so long, you
have made it all so easy.
This list and its inhabitants are way cool.
Many many thanks
Darren
----- Original Message -----
From: "John Skolits" <askolits at ot.com>
To: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>
Sent: Wednesday, October 22, 2003 11:46 PM
Subject: RE: [AccessD] A2K: Regsvr32 assistance please
>
> You can use the Shell, but I sometimes ran into problems with it.
> This function will actually return a True or False if its registered or
not.
>
> Here's an example on how to use it:
>
> Register The Control
> call lbf_RegisterOCX("c:\winnt\system32\comdlg32.ocx",true)
>
> Unregister control
> call lbf_RegisterOCX("c:\winnt\system32\comdlg32.ocx",true)
>
>
>
> Here's the code I use:
> ---------------------------------------------
>
>
>
> Option Compare Database
> Option Explicit
>
> Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lLibFileName
As
> String) As Long
> Private Declare Function CreateThread Lib "kernel32" (lThreadAttributes As
> Any, _
> ByVal lStackSize As Long, ByVal lStartAddress As Long, ByVal larameter
> As Long, _
> ByVal lCreationFlags As Long, lThreadID As Long) As Long
> Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle
> As Long, _
> ByVal lMilliseconds As Long) As Long
> Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As
> Long, _
> ByVal lProcName As String) As Long
> Private Declare Function CallWindowProc Lib "user32" Alias
"CallWindowProcA"
> _
> (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, _
> ByVal wParam As Long, ByVal lParam As Long) As Long
> Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As
> Long) As Long
> Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As
Long)
> As Long
> Private Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread
As
> Long, _
> lExitCode As Long) As Long
> Private Declare Sub ExitThread Lib "kernel32" (ByVal lExitCode As Long)
>
>
>
>
> Function lbf_RegisterOCX(ByVal sFilePath As String, _
> Optional bRegister As Boolean = True) As Boolean
>
> Dim lLibAddress As Long, lProcAddress As Long, lThreadID As Long, _
> lSuccess As Long, lExitCode As Long, lThread As Long
> Dim sRegister As String
>
>
''**************************************************************************
> ******
> '' Procedure Identification
>
''--------------------------------------------------------------------------
> ------
> '' Name: lbf_RegisterOCX
> ''
> '' Purpose: This function registers and Unregisters OLE components
> ''
> '' Results: Returns True if successful
> ''
> '' Inputs: sFilePath - The path to the DLL/OCX or ActiveX EXE
> '' bRegister - If True Registers the control, else
unregisters
> control
> ''
> ''
> '' Date/Author: Andrewb 04/09/2000 Loaded into CDD Lib 10/07/03 John
> Skolits
>
''**************************************************************************
> ******
>
> On Error GoTo lbf_RegisterOCX_ERR
>
> '*********BEGIN CODE HERE ********
> Const clMaxTimeWait As Long = 20000 'Wait 20 secs for register to
> complete
>
> If Len(sFilePath) > 0 And Len(Dir(sFilePath)) > 0 Then
> 'File exists
> If UCase$(Right$(sFilePath, 3)) = "EXE" Then
> 'Register/Unregister ActiveX EXE
> If bRegister Then
> 'Register EXE
> Shell sFilePath & " /REGSERVER", vbHide
> Else
> 'Unregister ActiveX EXE
> Shell sFilePath & " /UNREGSERVER", vbHide
> End If
> lbf_RegisterOCX = True
> Else
> 'Register/Unregister DLL
> If bRegister Then
> sRegister = "DllRegisterServer"
> Else
> sRegister = "DllUnRegisterServer"
> End If
>
> 'Load library into current process
> lLibAddress = LoadLibraryA(sFilePath)
>
> If lLibAddress Then
> 'Get address of the DLL function
> lProcAddress = GetProcAddress(lLibAddress, sRegister)
> If lProcAddress Then
> lThread = CreateThread(ByVal 0&, 0&, _
> ByVal lProcAddress, ByVal 0&, 0&, lThread)
> If lThread Then
> 'Created thread and wait for it to terminate
> lSuccess = (WaitForSingleObject(lThread,
> clMaxTimeWait) = 0)
> If Not lSuccess Then
> 'Failed to register, close thread
> Call GetExitCodeThread(lThread, lExitCode)
> Call ExitThread(lExitCode)
> lbf_RegisterOCX = False
> Else
> 'Successfully registered component
> lbf_RegisterOCX = True
> Call CloseHandle(lThread)
> End If
> End If
> Call FreeLibrary(lLibAddress)
> Else
> 'Object doesn't expose OLE interface
> Call FreeLibrary(lLibAddress)
> End If
> End If
> End If
> End If
> Exit Function
>
> lbf_RegisterOCX_EXIT:
>
> Exit Function
>
> lbf_RegisterOCX_ERR: 'Display the error
>
>
> MsgBox "ERROR CODE:" & Err & " DESC:" & Error
>
> Resume lbf_RegisterOCX_EXIT
>
> End Function
>
>
>
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com