GetFirstObject Method  
 
BOOL GetFirstObject(
  LPWEB_STORAGE_OBJECT lpObject  
);
BOOL GetFirstObject(
  LPCTSTR lpszMatchLabel,  
  LPWEB_STORAGE_OBJECT lpObject  
);
BOOL GetFirstObject(
  LPCTSTR lpszMatchLabel,  
  LPCTSTR lpszContentType,  
  LPWEB_STORAGE_OBJECT lpObject  
);

The GetFirstObject method returns information about the first storage object that matches the specified label or content type.

Parameters

lpszMatchLabel
A null-terminated string which specifies the value to match against the object labels in the container. The string may contain wildcard characters similar to those use with the Windows filesystem. A "?" character matches any single character, and "*" matches any number of characters in the label. If this parameter is omitted, a NULL pointer or an empty string, all objects in the container will be matched.
lpszContentType
A null-terminated string which specifies the content type of the objects to be enumerated. If this parameter is omitted, a NULL pointer or an empty string, the content type is ignored and all matching objects are returned. If a content type is specified, it must be a valid MIME media content type designated using the type/subtype nomenclature.
lpObject
A pointer to a WEB_STORAGE_OBJECT structure that will contain information about the storage object when the function returns. This parameter cannot be NULL.

Return Value

If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. To get extended error information, call WebGetLastError.

Remarks

The GetFirstObject method returns information about the first object that matches a given label, content type or both. It is used in conjunction with the GetNextObject method to enumerate all of the matching objects in the storage container.

This method provides an alternative to the EnumObjects method, which populates an array of WEB_STORAGE_OBJECT structures. In some cases, iterating over each object in a loop may be preferred to preallocating memory for an array to store every matching object. Using GetFirstObject and GetNextObject is more efficient when the container contains a large number of objects that match the specified label and/or content type.

You cannot intermix calls between GetFirstObject and EnumObjects. The EnumObjects method will reset the internal object cache for the client session and subsequent calls to GetNextObject will fail.

Example

WEB_STORAGE_OBJECT webObject;

if (pStorage->GetFirstObject(&webObject))
{
    do
    {
        // Print information about each object
        _tprintf(_T("Object: %s\n"), webObject.szObjectId);
        _tprintf(_T("Label: %s\n"), webObject.szLabel);
        _tprintf(_T("Size: %lu\n"), webObject.dwObjectSize);
        _tprintf(_T("Digest: %s\n"), webObject.szDigest);
        _tprintf(_T("Content: %s\n"), webObject.szContent);
        _tprintf(_T("\n"));
    }
    while (pStorage->GetNextObject(&webObject));
}

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cswebv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also