Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does any one can give example of how to write dll in vfp
Message
De
11/02/2000 08:37:04
 
 
À
11/02/2000 02:13:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00330547
Message ID:
00330605
Vues:
9
>Hi,
>To all
>does anyone know how to write a dll and invoke it in visual foxpro.
>Can you give an illustration of this.
>
>
>REgards,
>sunil

VFP is capable of creating COM objects. These can be compiled into either a DLL or and EXE. There are advantages and disadvantages of both:

- EXE: Called an out-of-process server. Can have a user interface. Runs in it's own memory space, so if it crashes, it doesn't crash your application. Is slower than DLL because data has to move across process boundaries (this is called marshalling).

- DLL: Called an in-process server. Cannot have a user interface. Runs in the same memory space as your application, so if it crashes, your application crashes. Is faster than an EXE COM server because data does not have to move across process boundaries. If you want to run your COM object in MTS, it must be compiled as a DLL.

You build a COM server by marking your class OLEPUBLIC. If you designed the class visually, from the class designer make the following menu selections:
Class > Class Info. Then from the Class tab, check "OLE Public". If you designed the class in code, you add the OLEPUBLIC keyword. For example:

DEFINE CLASS MyTest AS Custom OLEPUBLIC
ENDDEFINE

Now, when you compile the project, you determine if you want an in-process or out-of-process server. There are three selections on the Build dialog:

- Win32 Executable/COM server (EXE). This builds an out of process server.

- Single threaded COM server (DLL). This builds an in-process COM server. If you are distributing the DLL to a user PC, this is the choice to make.

- Mult-threaded COM Server (DLL). This builds an in-process COM server. If you are running the DLL on a server or in MTS and expect multiple user to hit the server, this is the choice to make.

Now, to invoke your server, you use the same syntax for both in-proc and out-of-proc servers:

ox = CREATEOBJECT("MyServer.MyTest")

Then, you have access to all the public methods and properties.

I suggest you read chapter 16 of the VFP 6.0 Programmer's Guide. Particularly the section "Creating Automation Servers"
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform