Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Callback (again)
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01144964
Message ID:
01145130
Views:
16
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
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform