Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel variables and VFP
Message
 
À
13/09/2004 04:55:13
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00937401
Message ID:
00941946
Vues:
27
Cetin, Thanks so much,
STeve
** see if DLL is registered
unReg = 1
if unReg = 1
IF FILE("VfpOpubTest.DLL")
	WAIT WINDOW "found VfpOpubTest.DLL    removing it"
   	DECLARE integer DllUnregisterServer IN VfpOpubTest.DLL
   	DllUnregisterServer()
   	CLEAR DLLS
ENDIF
endif

if _IsClassRegistered("VfpOpubTest.TestClass")
	WAIT WINDOW "VfpOpubTest.TestClass" + " is registered"
ELSE
	WAIT WINDOW "VfpOpubTest.TestClass" + " is not registered"
	DO make_dll && will build it and register it
endif

function _IsClassRegistered
	lparameters tcClass
	#DEFINE HKEY_CLASSES_ROOT    -2147483648
	#DEFINE ERROR_SUCCESS		0	&& OK

	DECLARE Integer RegOpenKey IN Win32API ;
		Integer nHKey, String @cSubKey, Integer @nResult

	DECLARE Integer RegCloseKey IN Win32API ;
		Integer nHKey

	local lnKey
	lnKey = 0
	llRetVal = ( RegOpenKey(HKEY_CLASSES_ROOT, tcClass, @lnKey) = ERROR_SUCCESS )
	if llRetVal
	  RegCloseKey(lnKey)
	endif
	*vfp7 and up
	*CLEAR DLLS 'RegOpenKey', 'RegCloseKey'
	return llRetVal
EndFunc
** if DLL not registered do so
clear
clear DLLS
release all like o*
SET SAFETY off
CD c:\page0

** take the proc from the class to a file
? "sending PricesPre to class definition"
SET CLASSLIB TO pager
omatch 	= CREATEOBJECT("match_quiet")
********* the proc you are taking is here
lcText	= GETPEM("match_quiet",'pricespre_paste')
STRTOFILE(lcText,"myCode.txt")  && the proc code is here now

** to hold class definition
CREATE TABLE myProc (myLine c ( 200) )

** this will be top part of your class definition
**********************8
Text to myHeader noshow
	******************
	DEFINE CLASS 	testclass 				as Session olepublic	&& name of CLASS
	*************
	PROCEDURE 	PricesPre_PASte(pLast 	as String) 				&& next comes the proc
EndText
**********************8
StrToFile(MyHeader, "myHead.txt")

** this will be bottom part of class definition
**********************8
Text to myFooter noshow
	ENDPROC	&& this follows the proce
	*****************8
	EndDefine	&&**  end of class definition
	**************************8
EndText
StrToFile(MyFooter, "myFoot.txt")
**********************8

** create a table with the class definition
sele myProc  && the table
appe from myHead.txt type sdf   && top part of class
appe from myCode.txt type sdf		&& actual code for proc
appe from myfoot.txt type sdf	&& bot part of class definition

copy to oPubClass.prg type sdf

******* here you build project then DLL
? "building project"
Build Project 	VFPopubtest From oPubClass.prg			&& name of DLL and project
? "build DLL"
Build Mtdll 	VFPopubtest From VFPopubtest recompile	&& build DLL from project
******** 
******** done

********************************* for Excel **************  see oVFP.xls
forEx = 0
if ForEx = 1
text
Function oVFP(myName As String)
    Dim myVFP_COM As Object
    Set myVFP_COM = CreateObject("VfpOpubTest.TestClass")
    oVFP = myVFP_COM.GetCustomerAmt(myName)
    Set myVFP_COM = Nothing
End Function
endtext
ENDIF
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform