Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Callback (again)
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01144964
Message ID:
01145130
Vues:
13
Would it make any difference if I use that code to communicate between two different components: EXE and DLL?

>>Can someone please provide a sample code for a callback operation between two com components? One is VFP exe, another is VFP DLL.
>>
>>Thanks a lot for help.
>
>Create a project named "TestCallback", then add a PRG with this in it:
>
>
>DEFINE CLASS COMOne AS Session OLEPUBLIC
>   oCallback = NULL
>
>   FUNCTION AddCallback(toCallback AS Object)
>      IF VARTYPE(toCallback) = "O"
>         This.oCallback = toCallback
>      ENDIF
>   ENDFUNC
>
>   FUNCTION Process
>      LOCAL liCount
>
>      FOR liCount = 1 TO 10
>          This.CallbackEvent(liCount)
>      ENDFOR
>   ENDFUNC
>
>   PROTECTED FUNCTION CallbackEvent(tiCount AS Integer)
>      IF VARTYPE(This.oCallback) = "O"
>         * Assumption is that object supports correct interface
>         * If not, it will throw an exception
>         This.oCallback.OnCallbackEvent(tiCount)
>      ENDIF
>   ENDFUNC
>ENDDEFINE
>
>DEFINE CLASS COMTwo AS Session OLEPUBLIC
>   FUNCTION OnCallbackEvent(tiCount AS Integer)
>      STRTOFILE(TRANSFORM(tiCount) + CHR(13), "C:\TestLog.txt", 1)
>   ENDFUNC
>ENDDEFINE
>
>
>To run the code:
>
>Build the EXE
>
>From the command line:
>
>o = CREATEOBJECT("TestCallback.COMOne")
>ox = CREATEOBJECT("TestCallback.COMTwo")
>o.AddCallback(ox)
>o.Process()
>
>To check that it worked:
>
>MODIFY FILE C:\TestLog.txt
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform