IStillImage::StiCreateInstance method

The IStillImage::StiCreateInstance method creates an instance of the COM object that defines the IStillImage interface, and returns a pointer to the interface.


HRESULT StiCreateInstance(
   HINSTANCE   hinst,
   DWORD       dwVer,
   PSTI        *ppSti,
   LPUNKNOWN   punkOuter


  • hinst
    Caller-supplied instance handle of the calling process. This handle is obtained by calling GetModuleHandle(NULL).

  • dwVer
    Caller-supplied STI version number. This value must be STI_VERSION, defined in Sti.h.

  • ppSti
    Receives a pointer to the IStillImage interface.

  • punkOuter
    Optional, caller-supplied pointer to the "controlling unknown" for object aggregation. See the following Remarks section.

Return value

If the operation succeeds, the method returns S_OK. Otherwise, it returns one of the STIERR-prefixed error codes defined in stierr.h.


For an application to use the IStillImage interface, it must first call IStillImage::StiCreateInstance to get a pointer to the interface. The pointer received in ppSti is used subsequently when calling IStillImage methods, as illustrated in the following example:

DWORD dwStiTotal = 0;     // total number of STI devices found
PVOID pStiInfo = NULL;    // STI device info buffer
HRESULT hres = StiCreateInstance(GetModuleHandle(NULL), STI_VERSION, &pSti, NULL);
hhes = pSti->GetDeviceList(0, 0, &dwStiTotal, &pStiInfo);

If you want to create an aggregate COM object that includes IStillImage, you must supply a pointer to the "controlling unknown" in punkOuter. In most cases you will not be creating an aggregate object, so punkOuter should be NULL. Object aggregation and the controlling unknown are described in the Microsoft Windows SDK documentation and in the Component Object Model Specification.


Target platform



Sti.h (include Sti.h)

See also




Send comments about this topic to Microsoft