Article ID: 132212
Article Last Modified on 10/30/2006
APPLIES TO
- Microsoft Mail for PC Networks 3.0
- Microsoft Mail for PC Networks 3.2
This article was previously published under Q132212
NOTE: The information supplied here is not supported by Microsoft; we make no warranty, implied or otherwise, regarding this codes' performance or reliability.
The following code fragment illustrates one way to obtain the user name and address of the currently logged in account. The following calls use CMC.DLL as a static library. The code was compiled, linked and executed successfully using Microsoft Visual C++ version 1.5.
/* cmc_who.c */ /* This code fragment displays */ /* the currently logged in user */ #include <stdio.h> #include <string.h> #include <windows.h> #include <xcmc.h> #include <client.h> #include <xcmcext.h> #include <xcmcmsxt.h> #include <pvalloc.h> int cmc_who(void); int main(void) { cmc_who(); return 0; } int cmc_who(void) { CMC_recipient FAR *pRecipient; CMC_uint32 count; CMC_return_code err; CMC_session_id session; char szBuf[100]; char szBuf2[100]; char szMsg[100]; char szMsg2[100]; count = 0; err = cmc_logon("", "", "", NULL, 0, 100, CMC_LOGON_UI_ALLOWED,\ &session, 0); /* look up currently logged in user */ err = cmc_look_up(session, NULL, CMC_LOOKUP_RESOLVE_IDENTITY |\ CMC_ERROR_UI_ALLOWED, (CMC_ui_id)NULL, &count, &pRecipient, NULL); if(err != CMC_SUCCESS) MessageBox(0, "Error during cmc_look_up", "Error", MB_OK); strcpy(szMsg, "Logged in user name: "); strcpy(szMsg2, "Logged in user address: "); /* copy the appropriate recipient fields into the */ /* respective buffers */ _fstrcpy(szBuf, pRecipient -> name); _fstrcpy(szBuf2, pRecipient -> address); strcat(szMsg, szBuf); // add the data to the descriptions strcat(szMsg2, szBuf2); MessageBox(0, szMsg, "Who Am I", MB_OK); MessageBox(0, szMsg2, "Who Am I", MB_OK); cmc_free(pRecipient); // free the recip buffer err = cmc_logoff(session, 0, CMC_LOGOFF_UI_ALLOWED && \ CMC_ERROR_UI_ALLOWED, NULL); return 0; } /* end cmc_who.c */
Additional query words: 3.20 3.20a sample code who am I mapi
Keywords: KB132212