Click here to Skip to main content
15,908,173 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDuplicate a file? Pin
mcgahanfl20-May-05 4:36
mcgahanfl20-May-05 4:36 
AnswerRe: Duplicate a file? Pin
Tom Wright20-May-05 4:52
Tom Wright20-May-05 4:52 
GeneralRe: Duplicate a file? Pin
mcgahanfl23-May-05 2:44
mcgahanfl23-May-05 2:44 
AnswerRe: Duplicate a file? Pin
Tom Archer20-May-05 17:00
Tom Archer20-May-05 17:00 
GeneralRe: Duplicate a file? Pin
mcgahanfl23-May-05 2:45
mcgahanfl23-May-05 2:45 
GeneralMemory full error in C++ DLL Pin
Ashish Chauhan20-May-05 4:22
Ashish Chauhan20-May-05 4:22 
GeneralRe: Memory full error in C++ DLL Pin
David Crow20-May-05 6:44
David Crow20-May-05 6:44 
GeneralRe: Memory full error in C++ DLL Pin
Ashish Chauhan20-May-05 20:31
Ashish Chauhan20-May-05 20:31 
Sorry for less information.

I have written a function which returns all the contacts of outlook Express in this function I opened the WAB32.dll file using the loadlibrary function and then retrieve all the contacts and append then to the char * variable.
below is my function which explains you properly.

This function is frequently called by VB 6.0 DLL. if i have not more than 50 contacts it will work fine but when i have more than that it gives me "Low virtual memory " error occurs and then my whole system goes down.

Please give a solution to resolve the problem.

One more problem is that is it right way to returns the character array from VC ++ to VB 6.0?. please modify the code or give me good suggestion because VB recongnizes String and VC++ recongnizes char Array.


char *CNewOutlookExpressApp::GetWABListInStr () //Member function.
{

HRESULT hRes;
HINSTANCE hinstLib;
try
{
LPADRBOOK lpAdrBook;//Object of Address book
LPWABOBJECT lpWABObject; //Object of WAB
// LPWAB_PARAM lpWABParam ;
DWORD Reserved2 =NULL ;
fWABOpen procWABOpen;
// IABContainer *lpContainer ;
LPMAPITABLE lpTable ; //holds the image of windows address book in table format.

hRes = UpdateContactID () ;

if (hRes != 0 )
{
throw "Error";
}

ULONG ulRows;
//wab32FilePath
hinstLib = LoadLibrary(wab32FilePath); //Open the library file. file must be like C:\\Program Files\\Common Files\\System\\wab32

if (hinstLib != NULL) //Start of hinstLib Condition
{
procWABOpen = (fWABOpen) GetProcAddress(hinstLib, "WABOpen"); // get the address of WABOpen method.
if ( procWABOpen != NULL )
{
WAB_PARAM wp = {0};
wp.cbSize = sizeof(WAB_PARAM);

// Only want to deal with "Main Identity's Contacts"
wp.ulFlags = WAB_ENABLE_PROFILES;


// Creates an instance of our IAddrBook interface
// which will give us access to the WAB.

hRes = (procWABOpen)(&lpAdrBook,&lpWABObject,&wp,Reserved2); // wp parameter retrieves the Main Identity's contacts.if user pass null user can get all contacts.

_ASSERTE(hRes == S_OK);
if (hRes != S_OK)
{
exit(1);
}

ULONG lpcbEntryID;
ENTRYID *lpEntryID;
hRes = lpAdrBook->GetPAB(&lpcbEntryID,&lpEntryID); //gets the Personal Addres book.

_ASSERTE(hRes == S_OK);
if (hRes != S_OK)
exit(2);


ULONG ulFlags = MAPI_BEST_ACCESS; //it gives full access.
ULONG ulObjType = NULL;
LPUNKNOWN lpUnk = NULL;
hRes = lpAdrBook->OpenEntry(lpcbEntryID,lpEntryID,NULL,ulFlags,&ulObjType,&lpUnk); //open the entry.

ulFlags = NULL;
//IABTable *lpTable;

if (ulObjType == MAPI_ABCONT) //Make sure we have a Container object
{
IABContainer *lpContainer = static_cast <iabcontainer *="">(lpUnk);

hRes = lpContainer->GetContentsTable(ulFlags,&lpTable); //gets the value in lpTable variable

if ( hRes != 0) //if there is no contacts in list.
return NULL;

hRes = lpTable->GetRowCount(0,&ulRows); //returns the row count.

}

}
}


char *mainStr = NULL ;
// BSTR mainStr1 = NULL ;
mainStr = (char *) malloc(999999);

// ULONG ulRows ;
SRowSet *lpRows ; //variable for collection of rows.
//
// hRes = lpTable->QueryRows(ulRows,0,&lpRows); //stores the rows in lpRows and no of rows in ulRows variable.
hRes = lpTable->QueryRows(ulRows,0, &lpRows); //stores the rows in lpRows and no of rows in ulRows variable.

char ids[36][15]=
{"805503006","977600542","978255902","977535006",
"974192670","973471774","805371934","2148139038","974716958","974651422",
"974585886","974520350","975241246","975437854","973602846","978386974",
"975568926","975699998","975831070","975634462","975765534","974913566",
"975503390","973668382","978321438","978976798","979107870","979042334",
"978911262","979173406",
"977403968","977338432","978124802","805830720","805568542","977928222"};

char names[36][25] =
{"Email","Title","Nickname","MiddleName",
"LastName","FirstName","DisplayName","BusinessIPPhone" ,"BusinessOffice","BusinessDepartment",
"BusinessTitle","BusinessCompany","BusinessPager","BusinessFax","BusinessPhone","BusinessWebPage",
"BusinessCountry","BusinessState","BusinessZip","BusinessCity","BusinessAddress","HomeMobile",
"HomeFax","HomePhone","HomeWebPage","HomeCountry","HomeState","HomeZip",
"HomeCity","HomeAddress",
"BirthDate","AnniversaryDate","Gender","LastModifiedDateTime","Comment","ContactID"} ;

strcpy(mainStr ,"<root>" );

for(ULONG i=0;i< lpRows->cRows;i++) //row loop Record Loop
{
SRow *lpRow = &lpRows->aRow[i];
LPMAILUSER lpMailUser = NULL;
LPSPropValue v2;
int cb2;
ULONG cb;
LPBYTE lpb;
ENTRYID* entryID;

ULONG templpPropID ;
// ADRENTRY *lpRow = &adrList->aEntries[i];
// cout<<"Columns : " <<lprow->cValues <<endl;
for(ulong="" j="0;j<" lprow-="">cValues;j++) //Column loop
{
// SPropValue *lpProp = &lpRow->lpProps[j];
SPropValue *lpProp = &lpRow->lpProps[j];
lpProp->dwAlignPad = 0;

// cout << " " << j << " ID : " << (void*)lpProp->ulPropTag << " : "<<endl;
templppropid="(ULONG)" lpprop-="">Value.lpguid ;
/* if (lpProp->ulPropTag == 975634463)
{
// cout<<"Entry ID : " <<lpprop->ulPropTag << " "<< lpProp->Value.lpszA <<endl;
fprintf(fp,"\"%ld\",",="" lpprop-="">ulPropTag);
lpb = lpProp->Value.bin.lpb;
entryID = (ENTRYID*)lpProp->Value.bin.lpb;
cb = lpProp->Value.bin.cb;
// break;
}
*/
if (lpProp->ulPropTag == PR_ENTRYID)
{
// cout<<"Entry ID : " <<lpprop->ulPropTag << " "<< lpProp->Value.lpszA <<endl;
lpb="lpProp-">Value.bin.lpb;
entryID = (ENTRYID*)lpProp->Value.bin.lpb;
cb = lpProp->Value.bin.cb;
break;
}
}
// getch();
// break;
///////////////////////////////////
ULONG ulObjType = NULL;
LPUNKNOWN lpUnk = NULL;

hRes = lpAdrBook->OpenEntry(cb,entryID,NULL,0,&ulObjType,(LPUNKNOWN *)&lpMailUser);
if (hRes != S_OK)
continue;

if ( ulObjType == 8 ) //if ulObjType holds 6 it means it is a contact and 8 means group , so we ignores groups.
continue ;



hRes = lpMailUser->GetProps( NULL, 0, (ULONG*)&cb2, &v2 );


//
// If GetProps (read "Get Properties") failed
// just skip it - something must be whack.
//
if (hRes != S_OK)
continue;
int row = 0 ;
char trf[5000] ;

sprintf( trf , "<record>");
strcat(mainStr , trf );

for ( row = 0 ; row < 36 ; row++ ) //loop according to IDs in Array
{
bool isIdExists = false ;
char trf[20] ;

for ( int x=0;x<cb2;x++)
{
="" sprintf(="" trf="" ,="" "%u",v2[x].ulproptag);
="" if="" (="" strcmp(ids[row],trf)="=" 0="" )
="" strcmp(ids[row],"805830720")="=" ||="" strcmp(ids[row],"977403968")="=" strcmp(ids[row],"977338432")="=" 0)="" for="" modification="" date,="" birthdate,="" anniversary="" date
="" writedatetimeinstr="" mainstr="" v2[x].value.ft="" ids[row],names[row]="" );
="" }
="" else="" strcmp(ids[row],"978124802")="=" )="" gender
="" "<tag="" id="\"%s\"" name="\"%s\"" value="\"%d\"/">",ids[row],names[row],v2[x].Value.b);
sprintf( trf , "<tag><id>%s<name>%s<value>%d",ids[row],names[row],v2[x].Value.b);
strcat(mainStr , trf );
}
else
{
// sprintf( trf , "<tag id="\"%s\"" name="\"%s\"" value="\"%s\"/">",ids[row],names[row],v2[x].Value.lpszA);
sprintf( trf , "<tag><id>%s<name>%s<value>",ids[row],names[row],v2[x].Value.lpszA);
strcat(mainStr , trf );
}
isIdExists = true ;
break;
}
}

if ( isIdExists == false )
{
// sprintf( trf , "<tag id="\"%s\"" name="\"%s\"" value="\"%s\"/">",ids[row],names[row]," ");
sprintf( trf , "<tag><id>%s<name>%s<value>%s",ids[row],names[row]," ");
strcat(mainStr , trf );
}

}
sprintf( trf , "");
strcat(mainStr , trf );
lpWABObject->FreeBuffer(lpRow);
} //End of Record Loop
strcat(mainStr ,"" );
lpWABObject->FreeBuffer(lpRows);
hRes = FreeLibrary(hinstLib);
// mainStr1 = (unsigned short *) mainStr ;
return mainStr ;
}
catch (...)
{
hRes = FreeLibrary(hinstLib);
return " " ;
}
}
GeneralRe: Memory full error in C++ DLL Pin
ThatsAlok20-May-05 22:15
ThatsAlok20-May-05 22:15 
GeneralRe: Memory full error in C++ DLL Pin
David Crow23-May-05 2:06
David Crow23-May-05 2:06 
QuestionHow to return character array from C++ DLL to VB 6.0 DLL Pin
Ashish Chauhan20-May-05 4:19
Ashish Chauhan20-May-05 4:19 
AnswerRe: How to return character array from C++ DLL to VB 6.0 DLL Pin
Tom Wright20-May-05 4:47
Tom Wright20-May-05 4:47 
AnswerRe: How to return character array from C++ DLL to VB 6.0 DLL Pin
David Crow20-May-05 6:45
David Crow20-May-05 6:45 
GeneralRe: How to return character array from C++ DLL to VB 6.0 DLL Pin
Ashish Chauhan20-May-05 21:18
Ashish Chauhan20-May-05 21:18 
GeneralRe: How to return character array from C++ DLL to VB 6.0 DLL Pin
David Crow23-May-05 2:00
David Crow23-May-05 2:00 
Generaltelnet Pin
ben y20-May-05 3:45
ben y20-May-05 3:45 
GeneralRe: telnet Pin
Tom Wright20-May-05 5:08
Tom Wright20-May-05 5:08 
GeneralSimple question about STL list class Pin
Budric B.20-May-05 3:31
Budric B.20-May-05 3:31 
GeneralAlso... Pin
Budric B.20-May-05 3:35
Budric B.20-May-05 3:35 
GeneralOoops Pin
Budric B.20-May-05 3:39
Budric B.20-May-05 3:39 
GeneralRe: Simple question about STL list class Pin
Cedric Moonen20-May-05 3:43
Cedric Moonen20-May-05 3:43 
Generalpocket pc application Pin
Mohanraj.K20-May-05 3:22
Mohanraj.K20-May-05 3:22 
GeneralPocket PC application development Pin
Mohanraj.K20-May-05 3:20
Mohanraj.K20-May-05 3:20 
GeneralRe: Pocket PC application development Pin
GDavy20-May-05 8:17
GDavy20-May-05 8:17 
QuestionHeight of status bar? Pin
One Stone20-May-05 3:15
One Stone20-May-05 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.