CWebStorage::GetObjectTime Method  
 
BOOL GetObjectTime(
  LPCTSTR lpszObjectLabel,  
  LPFILETIME lpTimeCreated,  
  LPFILETIME lpTimeModified  
);
BOOL GetObjectTime(
  LPCTSTR lpszObjectLabel,  
  LPSYSTEMTIME lpTimeCreated,  
  LPSYSTEMTIME lpTimeModified  
);

The GetObjectTime method returns the creation and last modification time of the stored object.

Parameters

lpszObjectLabel
A null-terminated string that specifies the label of the storage object. This parameter cannot be a NULL pointer.
lpTimeCreated
A pointer to a FILETIME structure which will contain the time the storage object was created when the method returns. If this information is not required, the parameter may be NULL. An alternate version of this method accepts a pointer to a SYSTEMTIME structure instead of a FILETIME structure.
lpTimeModified
A pointer to a FILETIME structure which will contain the time the storage object was last modified when the method returns. If this information is not required, the parameter may be NULL. An alternate version of this method accepts a pointer to a SYSTEMTIME structure instead of a FILETIME structure.

Return Value

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

Remarks

The GetObjectTime method is used to retrieve the creation and modification times for a stored object on the server. This method can also be used as a simple method to determine if the specified object exists. Each of the LPFILETIME or LPSYSTEMTIME parameters are optional and may be NULL if either the creation or modification times are not needed. If a pointer to a structure is provided, its members will be initialized to zero and then updated with the creation and/or modification time if the method succeeds.

Although storage object labels are similar to Windows file names, they are case-sensitive. When requesting the size of an object, your application must specify the label name exactly as it was created. The object label cannot contain wildcard characters.

If you wish to obtain all of the metadata associated with a specific object with a single method call, including the size, content type, creation and modification times, use the GetObjectInformation method.

Example

// Check if the object exists
FILETIME ftCreated;
FILETIME ftModified;

if (pStorage->GetObjectTime(lpszObjectLabel, &ftCreated, &ftModified))
{
    // The object exists, display the last modification time
    TCHAR szLocalDate[128];
    TCHAR szLocalTime[128];
    FILETIME ftLocalTime;
    SYSTEMTIME stLocalTime;
    
    FileTimeToLocalFileTime(&ftModified, &ftLocalTime);
    FileTimeToSystemTime(&ftLocalTime, &stLocalTime);
    
    GetDateFormat(LOCALE_USER_DEFAULT,
                  DATE_SHORTDATE,
                  &stLocalTime,
                  NULL,
                  szLocalDate, 128);

    GetTimeFormat(LOCALE_USER_DEFAULT,
                  TIME_FORCE24HOURFORMAT,
                  &stLocalTime,
                  NULL,
                  szLocalTime, 128);    
    
    _tprintf(_T("The object \"%s\" was lasted modified on %s %s\n"), lpszObjectLabel, szLocalDate, szLocalTime);
}
else
{
    // The object times could not be determined, display an error
    CString strError;

    pStorage->GetErrorString(strError);    
    _tprintf(_T("Unable to get the size of \"%s\" (%s)\n"), lpszObjectLabel, (LPCTSTR)strError);
}

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