>You have to create a class and make it OLEPUBLIC to make it an OLE server. You create a public method that would do the ALTER TABLE command. Then you just call that method of the server.
>
>How you create the OLE server instance depends on the language you are trying to call the server from. From VFP and VB you can just CreateObject() the server, in VC++ you call the CreateDispatch() method of a class derived from COleDispatchDriver.
>
>Look in the \vfp\samples\servers folder for some code.
>
Here is the code that I wrote in Visual Foxpro.
******
define class vfield as custom olepublic
procedure insfld
parameters tabname,fldname,fldtype,fldsize
kpk = ""
kpk = "ALTER TABLE " + tabname + " ADD column " + ;
fldname + " " + datype + "(" + datsize + ")"
messagebox (kpk)
&kpk
endproc
enddefine
Now I created the DLL, and it created the DLL, but when I used the procedure
insfld from VB with following code,
**********
declare sub insfld lib "c:\temp1\vfield.dll" (st1 as atring, st2 as string, st3 as string, st4 as string)
call insfld("main.dbf","psr","C","20")
*********
It gave error , can't find insfld
************
One more question :
Can I use Fpole.dll to execute a Foxcommand from VB ?
I tried but it said Bad DLL calling.
Précédent
Suivant
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