Environment versions
Network:
Windows 2003 Server
Ok in the Init add this;
THISFORM.register()
Create a new method called register.
In the new register method add this;
LOCAL lcMsg,lcWindir
lcMsg = ""
IF !THISFORM.chkclass("mscomctl2.dtpicker")
* control not registered - copy the control to Sys32 and register it
IF MESSAGEBOX("Some PPAgent components are not registered, would you like to register them now?",36,"PPAgent Warning") = 6
* try and register the control
* copy the file to the windows\sys32 folder
lcWindir = ADDBS(THISFORM.getwindir())
IF !FILE((lcWindir + "mscomct2.ocx"))
COPY FILE (ADDBS(THISFORM.appdir) + "mscomct2.ocx") TO (lcWindir+"mscomct2.ocx")
ENDIF
IF !THISFORM.regclass(lcWindir+"mscomct2.ocx")
lcMsg = "Unable to register key components please contact Infosupport."
ENDIF
ELSE
lcMsg = "PPAgent cannot load as some components are not registered."
ENDIF
ENDIF
IF !EMPTY(lcMsg)
MESSAGEBOX(lcMsg,48,"PPAgent Error")
QUIT
ENDIF
********************
********************
Create new methods for chkclass,getwindir and regclass.
Add this to chkclass method
PARAMETERS p_class
#DEFINE HKEY_CLASSES_ROOT -2147483648
#DEFINE ERROR_SUCCESS 0 && OK
IF EMPTY(p_class)
RETURN .F.
ENDIF
LOCAL lnKey
DECLARE Integer RegOpenKey IN Win32API ;
Integer nHKey, String @cSubKey, Integer @nResult
DECLARE Integer RegCloseKey IN Win32API ;
Integer nHKey
lnKey = 0
llRetVal = ( RegOpenKey(HKEY_CLASSES_ROOT, p_class, @lnKey) = ERROR_SUCCESS )
IF llRetVal
RegCloseKey(lnKey)
ENDIF
RETURN llRetVal
***********************
***********************
Add this to getwindir method;
LOCAL lcWinDir,lnWinDirLen
DECLARE INTEGER GetSystemDirectory IN KERNEL32 STRING @, INTEGER
lcWinDir = SPACE(254)
lnWinDirLen = 254
lnWinDirLen = GetSystemDirectory(@lcWinDir, lnWinDirLen)
RETURN lcWinDir
***********************
***********************
add this to regclass method;
PARAMETERS p_file
LOCAL lnResult
IF EMPTY(p_file)
RETURN .F.
ENDIF
IF !FILE(p_file)
RETURN .F.
ENDIF
DECLARE DllRegisterServer IN (p_file)
lnResult = DllRegisterServer()
IF !lnResult
* error occurred registering dll
RETURN .F.
ENDIF
RETURN .T.
**********************
**********************
You will need to change the control being checked for and obviously the messages. This works in VFP6 but I see no reason it shouldnt work in VFP8.
Hope this helps.
>I put your code in the form init that contains the ActiveX control.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only