Click to See Complete Forum and Search --> : Weird pointer problem


azwaanameer
July 20th, 2007, 12:59 AM
i have a ATL COM/MFC C++ application that talks to another external C++ application.

the following is a structure that is defined in both applications identically as folows



struct stConfigInfo
{
CString strProductName;
CString strBomPath;
.....
...
stNestedConfInfo *pstNestedConf;

stConfigInfo()
{
strProductName = _T("");
strBomPath = _T("");
...
...
pstNestedConf = NULL;
}

~stConfigInfo()
{
}

};

struct stNestedConfInfo
{
CString strDMSessionID;

stNestedConfInfo()
{
strDMSessionID = _T("");
}
~stNestedConfInfo()
{
delete strDMSessionID;
}
};



im populating this structure in my application and sending it as a variant to the external application, like this,



VARIANT* varConfigInfo;

stConfigInfo* pstCfgInfo = new stConfigInfo;
pstCfgInfo->strProductName = pstrProduct;
pstCfgInfo->strBomPath = pstrBomPath;
...
...
pstCfgInfo->pstNestedConf = NULL;

'// casting structure to variant
varConfigInfo = (VARIANT*) pstCfgInfo;

// calling external application and passing variant
pDataManagerW->SetConfigInfo(varConfigInfo);



as you can see i have set the pstNestedConf to NULL , as i need to bypass some code logic in the external application.

but the problem is somehow even when i have set this to NULL, as soon as i enter the SetConfigInfo method of the external app , this evaluates to Not null.. , all other values i hav set in my application for the structure , r ok. but only this pstNestedConf value seem to have changed. any ideas why? and how i could resolve this?

in case ur wondering how i know that it is not null when i enter the method in the external app, i placed some code logic in the beginning of the method to test the values passed.