Help with MAPI properties please.
- From: carl_bevil@xxxxxxxxx
- Date: 21 May 2007 14:11:26 -0700
I've got a problem with MAPI properties. We have a combo box (drop-
list) which displays some options for the user when DoConfigPropSheet
is called. (...and currently there is only one option, so it's not
much of a list.) The code's not mine; I'm new to MAPI and am just
trying to fix bugs.
DoConfigPropsheet does an OpenProperty on the data associated with the
combo box. The OpenProperty method is part of a custom IMAPIProp
implementation. The implementation for the most part is just a
wrapper for an object created using the CreateIProp function with
IID_IMAPIPropData as the first parameter. Most all of the other
methods just pass the data on to the underlying object, but I can set
breakpoints to see what is happening.
It seems to work fine when getting properties: the combo box gets
populated with the appropriate string. But then when you try to set
the property by selecting the combo box and clicking off it
(DT_SET_IMMEDIATE is set), or clicking OK, I get an exception from
Outlook (in olmapi32.dll) with an IsBadReadPtr() call at the top of
the stack. The frustrating part is that it is not getting to the
SetProperty method; it seems to be throwing the exception before then
(possibly in preparation to call this method).
I'm hoping someone here can take a look at the following code and tell
me if you see anything wrong in it. I've tried to boil it down to
just the necessary code, but let me know if pieces are missing.
UNICODE (and _UNICODE for that matter) are not defined; all strings
should be ANSI strings.
-----------------------------
#define BASE_PROVIDER_ID 0x6600
#define PR_MY_PROPERTY PROP_TAG(PT_TSTRING, (BASE_PROVIDER_ID +
0x0003))
#define PR_MY_PROPERTY_TABLE PROP_TAG(PT_OBJECT, (BASE_PROVIDER_ID +
0X0006))
#define MAX_DISPLAY_NAME 128
#define MAX_STRING_SIZE 32
#define NUM_PROPERTIES 2
SizedSPropTagArray (NUM_PROPERTIES, sptListboxColumnSet) =
{
NUM_PROPERTIES,
{
PR_DISPLAY_NAME,
PR_MY_PROPERTY
}
};
void CALLBACK TableReleaseCallback(ULONG ulCallerData, LPTABLEDATA
lpTblData, LPMAPITABLE lpVue)
{
if (lpTblData)
{
lpTblData->Release();
}
}
STDMETHODIMP MYMAPIProp::OpenProperty (ULONG ulPropTag,
LPCIID piid,
ULONG
ulInterfaceOptions,
ULONG ulFlags,
LPUNKNOWN * ppUnk)
{
HRESULT hResult = E_NOINTERFACE;
LONG lResult= 0;
char szDisplayName[MAX_DISPLAY_NAME + 1];
DWORD cbDisplayName= MAX_DISPLAY_NAME;
char szInternalName[MAX_STRING_SIZE + 1];
DWORD cbInternalName= MAX_STRING_SIZE;
DWORD dwIndex= 0;
ValidateParameters( IMAPIProp_OpenProperty, ulPropTag );
if ( ( ulPropTag == PR_MY_PROPERTY_TABLE ) &&
( *piid == IID_IMAPITable ) )
{
LPTABLEDATA pListboxTable= NULL;
SPropValue sPropValues[NUM_PROPERTIES];
SRow sRow;
hResult= CreateTable( &IID_IMAPITableData,
GetMAPIAllocBuffer(),
GetMAPIAllocMore(),
GetMAPIFreeBuffer(),
NULL,
TBLTYPE_SNAPSHOT,
PR_MY_PROPERTY,
(LPSPropTagArray) &sptListboxColumnSet,
&pListboxTable);
if (SUCCEEDED(hResult))
{
sPropValues[0].ulPropTag= PR_DISPLAY_NAME;
sPropValues[0].Value.LPSZ= szDisplayName;
sPropValues[1].ulPropTag= PR_MY_PROPERTY;
sPropValues[1].Value.LPSZ= szInternalName;
sRow.ulAdrEntryPad= 0;
sRow.cValues= NUM_PROPERTIES;
sRow.lpProps= sPropValues;
// Here szDisplayName and szInternalName are populated from the
registry.
// The code enumerates registry entries, but there is only one
actual entry.
// The strings from the registry are well within the size limits
for the arrays.
hResult= pListboxTable->HrGetView(NULL, TableReleaseCallback, NULL,
(LPMAPITABLE*)ppUnk);
}
}
return hResult;
}
------------------------------
If it's any help, this issue came up in Windows Vista with Outlook
2007; AFAIK it works on other platforms.
Thanks in advance,
Carl
.
- Prev by Date: Re: Create a new outlook contact
- Next by Date: Re: Problem creating contact with CDO
- Previous by thread: Re: Create a new outlook contact
- Next by thread: Is there a way to discriminate between IMAP Message Store and other PST ?
- Index(es):
Relevant Pages
|