If the library will be used only by another VFP apps, then there is another
approach: Using an EXE as a library, so no need to register a DLL on the

*Approach 1:* Using VCX inside EXE

You just compile an EXE with your classlib and then use externally on other
VFP programs.
Let's say that youur library is called "mytestlib.vcx" and the class you
want to instantiate is called "operations", which have methods for
mathematical operations:

*- In you other VFP Apps:
oOps = NEWOBJECT("operations", "mytestlib.vcx", "test_obj.exe")
? oOps.get_sum(1,2)

*Approach 2:* Using your library not as VCX, but as PRG and doing it the
main program of the EXE

Let's say you have this program as the main program of the "test_obj.pjx"

* main_test_lib.prg
DEFINE CLASS MyClassLib as Custom
    FUNCTION Get_Sum(value1, value2)
        RETURN value1 + value2

Then, when you want to instantiate this class, you can do it this way:

SET PROCEDURE TO test_obj.exe
oOps = CREATEOBJECT("myclasslib")
? oOps.get_sum(1,2)

There are other approaches, but I think that any of these can be useful to

2016-12-01 11:07 GMT+01:00 Wollenhaupt, Christof <

> Hi Mike,
> I want to be able to instantiate an object of this class and use it to
> > validate some things like login and license validation.
> >
> This is one of the things that sound easier than they are in VFP due to the
> program cache and VFP's project scope management. The cleanest approach
> would be to have a main program in that EXE that instantiates the object:
> LParameter tcAction, roRef
> Do case
> Case Upper(m.tcAction) == "CREATE"
> roRef = NewObject("Test", "test.prg")
> EndCase
> Then build the EXE and call it like this:
> Local loTest
> Do Test.EXE with "CREATE", loTest
> ? loTest.Hello ()
> Obviously you would need to create your own set of actions and also handle
> parameters if your class needs those.
> A caveat, your other applications should not include a file or a class that
> has the same name as the ones in your EXE, or VFP can sometimes confuse
> both and crash.
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
>   text/plain (text body -- kept)
>   text/html
> ---
[excessive quoting removed by server]

Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to