Information générale
Catégorie:
Contrôles ActiveX en VFP
>If you have a new version of a ocx control which is to go onto a computer which already has an existing ocx control. Can you copy the new one over the old control without registering it or do you have to register the new control?..
>
>Any help would be grateful
>
>Dave
Dave
I use the code below on start-up.
1. Given a control, let's say "FOO.OCX" located at cPath, try to instantiate it on a fake form: TestOCX("FOO.OCX").
2. If the test fails, then: DllRegisterServerOCX(ADDBS(cPath) + "FOO.OCX")
There could be situations where DllRegisterServer (the function called if you type RegSvr32 at the command line) will fail, e.g. insufficient permissions, so that should be protected with an error handler as well.
I use it to check that a errant version of Office hasn't deregistered the common controls (see KB).
John Burton
******************************************************
FUNCTION TestOCX
LPARAMETERS cTestControlName
LOCAL oTestForm
oTestForm = CREATEOBJECT("ACTIVEXTESTFORM", cTestControlName)
RETURN oTestForm.Passed
ENDFUNC
DEFINE CLASS ACTIVEXTESTFORM AS FORM
Passed = .T.
PROCEDURE Error
LPARAMETERS nError, cMethod, nLine
THIS.Passed = .F.
ENDPROC
PROCEDURE Init
LPARAMETERS cTestControl
THIS.AddObject("oTestObj", cTestControl)
ENDPROC
ENDDEFINE
PROCEDURE DllRegisterServerOCX
LPARAMETERS cTestControlPath
DECLARE LONG DllRegisterServer IN (cTestControlPath)
= DllRegisterServer()
CLEAR DLLS DllRegisterServer
ENDPROC
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement