Help with MAPI properties please.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

.



Relevant Pages

  • The certification password of Internet Explorer 7 and operation of auto complete
    ... About the certification password of Internet Explorer and operation ... By remembering the strings that are input in the following text ... In this registry, there are values whose name is a string of 42 bytes ... We cannot guess the original strings from the hash value, ...
    (Bugtraq)
  • dynamic module loading via __import__, nonetype?
    ... I'm trying to create a setup which allows a program to request an object ... using strings and get an object of that type. ... I have a registry class which has a method to register a class. ...
    (comp.lang.python)
  • Re: Windows XP Welcome Screen
    ... assigning a password should prevent automatic logon. ... Microsoft MVP [Windows XP Shell/User] ... After I deleted all the strings in the registry, ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Windows XP Welcome Screen
    ... Configuration that worked. ... Once you are at the desktop, use your Browser and ... After I deleted all the strings in the registry, ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Damn you, FEDEX! or Nikon D40 lost in Springfield, MO blackhole.
    ... the 2 mp Mavica he had been using with a Nikon D40. ... After shopping around, he got me to order one for him. ... The shipper had it insured, but from what I have read it could take weeks to sort this crap out. ... You may get your insurance from FedEx and a couple weeks later they find it and deliver it. ...
    (alt.photography)