HOWTO: Get the Name of the Profile you Logged On WithLast reviewed: February 6, 1998Article ID: Q180597 |
The information in this article applies to:
SUMMARYThis article describes the process of programmatically determining what profile was used to log on to the current session.
MORE INFORMATIONTo find out which profile was used to start the current session, follow these steps:
// Note: Mapi32.lib is required to successfully compile and link // the following code. #include <mapix.h> #include <mapiutil.h> #include <stdio.h> HRESULT hr = S_OK; LPMAPISESSION lpSession = NULL; LPMAPITABLE lpStatusTable = NULL; SRestriction sres; SPropValue spvResType; LPSRowSet pRows = NULL; LPTSTR lpszProfileName = NULL; SizedSPropTagArray(2, Columns) = { 2, PR_DISPLAY_NAME, PR_RESOURCE_TYPE }; hr = MAPIInitialize(NULL); // Log on to the Extended MAPI session. hr = MAPILogonEx((ULONG)GetActiveWindow(), NULL, NULL, MAPI_LOGON_UI | MAPI_NEW_SESSION, &lpSession); hr = lpSession->GetStatusTable(NULL, &lpStatusTable); hr = lpStatusTable->SetColumns((LPSPropTagArray)&Columns, NULL); spvResType.ulPropTag = PR_RESOURCE_TYPE; spvResType.Value.ul = MAPI_SUBSYSTEM; sres.rt = RES_PROPERTY; sres.res.resProperty.relop = RELOP_EQ; sres.res.resProperty.ulPropTag = PR_RESOURCE_TYPE; sres.res.resProperty.lpProp = &spvResType; hr = lpStatusTable->Restrict(&sres, TBL_ASYNC); hr = lpStatusTable->FindRow(&sres, BOOKMARK_BEGINNING, 0); // We have a match. hr = lpStatusTable->QueryRows(1,0,&pRows); if (SUCCEEDED(hr)) { lpszProfileName = pRows->aRow[0].lpProps[0].Value.lpszA; printf("You logged onto profile \"%s\"\n", lpszProfileName); } |
Additional query words: Default Profile MAPILogonEx Session StatusTable
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |