Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Register ocx from within vfp
Message
From
19/01/2007 18:49:26
 
 
To
19/01/2007 18:28:51
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01187233
Message ID:
01187255
Views:
17
I wrote the following. Syntax to call (with example):
llOCX_OK = RegisterOCX("MSComCtl","MSComctlLib.TreeCtrl")
The first line is the
************************************************************************************************
*
*  Routine for checking the registration of OCX controls
*
FUNCTION RegisterOCX
LPARAMETERS  pcControlName,pcControlClass
LOCAL loOLEForm, llRtnCode, lcOCXFile, lcOCXTgt, llFileOK, lcSrcPath, lcOCXSrc, lcTLBSrc, lcTLBTgt, lcUserMsg
PUBLIC glOCXError
ON ERROR STORE .T. to glOCXError
glOCXError = .F.
loOLEForm = CREATEOBJECT('Form')
loOLEForm.AddObject('OCXTest','OLEControl',pcControlClass)
IF glOCXError
	lcOCXFile = FORCEEXT(pcControlName,".ocx")
	lcOCXTgt  = ADDBS(fGetSystemDir()) + lcOCXFile
	IF FILE(lcOCXTgt)
		DECLARE INTEGER DllRegisterServer IN (lcOCXFile) AS _DllRegisterServer
		IF _DllRegisterServer() != 0
			lcUserMsg = "Unable to register the OCX control" + pcControlName + "
			=MSGBOX(lcUserMsg,"System Message",16,"ERROR")
			llRtnCode = .F.
		ELSE
			llRtnCode = .T.
		ENDIF
	ENDIF
ELSE
	llRtnCode = .T.
ENDIF
loOLEForm.release()
RELEASE glOCXError
RETURN llRtnCode
ENDFUNC



FUNCTION fGetSystemDir
LOCAL lcDir, lnHossz
DECLARE INTEGER GetSystemDirectory IN WIN32API STRING @lcDir, INTEGER lnMaxHossz
lcDir = SPACE(256)
lnHossz = GetSystemDirectory(@lcDir,255)
IF lnHossz > 0
	RETURN LEFT(lcDir,lnHossz)
ELSE
	RETURN ""
ENDIF
ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform