WebGetFirstApplication Function  
 
BOOL WINAPI WebGetFirstApplication(
  LPWEB_STORAGE_APPLICATION lpAppInfo,  
  LPDWORD lpdwContext,  
);

The WebGetFirstApplication function returns information about the first registered application for the current storage account.

Parameters

lpAppInfo
A pointer to a WEB_STORAGE_APPLICATION structure that will contain information about the registered application when the function returns. This parameter cannot be NULL.
lpdwContext
A pointer to an unsigned integer that is used with subsequent calls to the WebGetNextApplication function. This parameter cannot be NULL.

Return Value

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

Remarks

The WebGetFirstApplication function returns information about the first registered application. It is used in conjunction with the WebGetNextApplication function to enumerate all of the registered application IDs associated with your storage account.

This function provides an alternative to the WebEnumApplications function, which populates an array of WEB_STORAGE_APPLICATION structures. In some cases, iterating through each AppID in a loop may be preferred to preallocating memory for an array to store every registered application. Using WebGetFirstApplication and WebGetNextApplication is more efficient when you have registered a large number of application IDs.

You cannot intermix calls between WebGetFirstApplication and WebEnumApplications. The WebEnumApplications function will reset the internal application ID cache for the client session and subsequent calls to WebGetNextApplication will fail. The cached application ID information used by this function is shared by the entire process. Attempting to enumerate all registered application IDs in multiple threads at the same time can yield unexpected results. It is recommended that multithreaded clients use a critical section to ensure that only a single thread is enumerating the AppIDs at any one time.

Example

WEB_STORAGE_APPLICATION webApp;
DWORD dwContext = 0;

if (WebGetFirstApplication(&webApp, &dwContext))
{
    do
    {
        // Print information for each registered application
        _tprintf(_T("AppId: %s\n"), webApp.szAppId);
        _tprintf(_T("Key: %s\n"), webApp.szApiKey);
        _tprintf(_T("LUID: %s\n"), webApp.szLuid);
        _tprintf(_T("Tokens: %lu\n"), webApp.dwTokens);
        _tprintf(_T("\n"));
    }
    while (WebGetNextApplication(&webApp, &dwContext));
}

Requirements

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

See Also

WebEnumApplications, WebGetNextApplication, WebRegisterAppId, WebUnregisterAppId