Partager via


Automation Server Programming Notes

To find additional information on writing automation servers, see the topics for the following areas.

Application Objects

An Application object is not exposed in an Automation server type library, therefore you cannot access the Application object DoCmd and Eval methods. However, you can expose the Application object by creating a custom property and setting its value to the Application object, or you can provide a method that accesses the Application object.

Note

Read/write properties of the Application object, such as AutoYield, are global to the project. Therefore, make sure multithreaded servers do not assume that the values of these settings are protected across threads.

For more information, see Application Object.

Automation Server Samples

This version of Visual FoxPro includes two sample ISAPI Automation servers, FoxWeb and FoxIS. These samples manage the return of selected Visual FoxPro records as HTML to an Internet browser. For more information about these samples, see FoxISAPI Automation Server Samples.

Note

FoxISAPI included in Visual FoxPro includes improvements designed specifically for use with new multithreaded DLL Servers. DLL Servers that are run through FoxISAPI should not use the built-in Pool Manager.

Configuration Files

In Visual FoxPro, only configuration files, Config.fpw, bound inside EXE or DLL servers will be used during run-time initialization. The configuration file stores critical settings that are set at the time Visual FoxPro starts up, both at product and run time. Prior to Visual FoxPro 6.0, the Config.fpw file could exist as a separate file or bound into the application (.app, .exe or .dll). If a Config.fpw file is found bound within an application, it is used. Otherwise, Visual FoxPro searches along normal paths for a separate Config.fpw file.

You will still get full functionality with normal distributed .app and .exe applications.

For more information, see How to: Set Configuration Options at Startup.

Codepage Handling

Codepages are supported in all servers and are specific to a particular project (.dll). You can set the default codepage in the Config.fpw file; however, it is set only at run-time initialization. The codepage is global across all projects. Also, all objects using a particular instance of the run time share the same codepage.

Each server has its own Config.fpw with a different codepage setting. Visual FoxPro prevents changing this setting once the run time has been launched because multiple .dll servers can potentially change the default codepage for a run time. Therefore, once a codepage is set, it is permanent until the run time is released.

Tip

Users who need servers with each having a unique codepage can place those servers, along with a copy of the VFP9T.dll run-time library, in a unique folder. A server will always default to using a run-time library stored in its folder. For more information, see VFP9T.DLL Run-Time Library.

Special Language Considerations

When working with automation servers, be aware of the functionality for following commands because their behavior differs slightly from normal product operations:

  • SET PROCEDURE command

    This command is unique to each individual thread because it is stored in thread local storage. However, Visual FoxPro implicitly performs a SET PROCEDURE to the entire server by default when you instantiate an .exe or .dll COM server.

    For example:

    ? SET("PROCEDURE")
    C:\VFP\MYSERVER.DLL
    

    This makes it possible for you to access any procedure stored in the server. If an existing object on the thread calls SET PROCEDURE, the procedure path is reset to nothing. However, a new object created on the same thread will automatically reset the procedure path to the entire server once again.

  • SET CLASS command

    This command works similarly to SET PROCEDURE. Its value is held in thread local storage; however, it is initialized to the entire set of class libraries in your .exe or .dll server.

    For example:

    ? SET("CLASS")
    C:\VFP\myClass.VCX ALIA
    
  • CD, CHDIR, and SET DEFAULT commands

    These commands change the default directory of the entire process, so they affect all threads that are part of the process. Instead of using CD, CHDIR, and SET DEFAULT, use the SET PATH command.

See Also

Tasks

How to: Create Automation Servers

Concepts

Selecting a Run-Time Library

Other Resources

Working with Automation Servers