In this lab you will return to the STUpload project. You will create an in-process COM server called STLoadData.dll, which hosts the UploadStockData component. This component exposes the IUploadStockData interface, which contains three methods: ConnectToDatabase(), Disconnect(), and UploadRecord().
Start by creating the STLoadData project within the STUpload workspace.
[in] BSTR fund, [in] DATE date, [in] double price, [in] BSTR uplBy, [in] DATE uplDate |
HRESULT ConnectToDatabase() |
and
HRESULT Disconnect() |
You will implement these methods in Lab 11 because they themselves are clients of other COM components (the ADO library).
Take a look at the STLoadData.idl file. Note particularly the interface definition:
[ object, uuid(241A7771-6888-11D3-934F-0080C7FA0C3E), dual, helpstring("IUploadStockData Interface"), pointer_default(unique) ] interface IUploadStockData : Idispatch { [id(1), helpstring("method UploadRecord")] HRESULT UploadRecord([in] BSTR fund, [in] DATE date, [in] double price, [in] BSTR uplBy, [in] DATE uplDate); [id(2), helpstring("method ConnectToDatabase")] HRESULT ConnectToDatabase(); [id(3), helpstring("method Disconnect")] HRESULT Disconnect(); }; |
Note how the IUploadStockData interface inherits from the IDispatch interface. This is how ATL implements a dual interface. Scripting clients will be able to use the UploadStockData component through the dispatch interface. Visual C++ and Visual Basic clients will be able to connect directly to the component's vtable.