Using the COM Implementation in a C/C++ Program
The following steps summarize typical programming tasks required to incorporate the functionality of the Fax Service Client API in a C/C++ fax client application if you are using the COM implementation.
To code a fax client application
- Create an instance of a FaxServer object by calling the CoCreateInstance function. Then connect to an active fax server using a call to the IFaxServer::Connect interface method. For more information, see Connecting to a Fax Server and IFaxServer.
- Create the objects you need by calling one or more of the following IFaxServer interface methods:
- The IFaxServer::GetJobs method to create a FaxJobs object. Use this object to create FaxJob objects and enumerate the fax jobs associated with the connected fax server.
- The IFaxServer::GetPorts method to create a FaxPorts object. Use this object to create FaxPort objects and enumerate fax port configuration information for a connected fax server.
- The IFaxServer::CreateDocument method to create a FaxDoc object. Use this object to transmit a fax and to retrieve and set the properties of FaxDoc objects.
- After creating an instance of a FaxPort object for a specific port, call the IFaxPort::GetRoutingMethods interface method to create a FaxRoutingMethods object. Also call the IFaxRoutingMethods::get_Item interface method to create a FaxRoutingMethod object. The FaxRoutingMethod object allows you to query and modify the fax routing information for a fax port. For more information, see Managing Fax Routing Data.
- To create a FaxStatus object, call the IFaxPort::GetStatus interface method. The FaxStatus object allows you to provide real-time status information about a fax port.
- After creating an instance of a FaxDoc object, transmit a fax document by calling the IFaxDoc::Send interface method. Note that the application must supply transmission information such as the fax number and the name of the file to transmit. The client can also supply other data that appears on the cover page by setting various properties of the FaxDoc object. For more information, see Transmitting Faxes.
- Call the SysFreeString function when appropriate to deallocate the resources allocated by all interface methods that end with get_PropertyName. For more information, see Freeing Fax Resources.
- Call the IFaxServer::Disconnect interface method to terminate the connection to the fax server. Then call the IUnknown::Release method to allow the FaxServer object to deallocate itself. For more information, see Disconnecting from a Fax Server.
In addition, the application may need to call other interface methods to query device or server configuration data, to manage fax jobs, and to destroy additional interface pointers. You may also need to create an instance of a FaxTiff object and call IFaxTiff interface methods to retrieve information about a file the fax service has sent or received.
Note that a client application must call the CoCreateInstance function to create an instance of a FaxServer or FaxTiff object. However, do not call the CoCreateInstance function to create FaxDoc, FaxJobs, FaxJob, FaxPorts, FaxPort, FaxStatus, FaxRoutingMethods, or FaxRoutingMethod objects. For more information about creating and deallocating fax client objects, see the steps listed with each interface topic and the hierarchical diagram in The Fax Client Object Model.
For more information, see Fax Server Configuration Management, Fax Device Management, Managing Fax Jobs, and General Fax Client Programming Tasks.