Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ActiveX registering
Message
De
18/02/2005 10:56:00
Jon Neale
Bond International Software
Wootton Bassett, Royaume Uni
 
 
À
18/02/2005 10:46:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
00988275
Message ID:
00988349
Vues:
47
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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform