|
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 " " ;
}
}
|
|
|
|
|
Ashish Chauhan wrote:
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
SAFEARRAY or Collection classes will help in this case
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Ashish Chauhan wrote:
mainStr = (char *) malloc(999999);
Where is the counterpart to this allocation?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have a problem is that how to return an char array from C++ DLL (This array has big data) to VB 6.0 DLL.
|
|
|
|
|
Take a look at this article ^.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
It sounds like you need to use a SAFEARRAY .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I know SAFEARRAY , BSTR, LPSTR all are good option to return character array (Large data) which is recognized by VB 6.0 as a string. But please give me an example that how to implement them.
|
|
|
|
|
Ashish Chauhan wrote:
But please give me an example that how to implement them.
How about MSDN article Q207931?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
how to send command to the server after being connecting by telnet
|
|
|
|
|
Same way that you would send anything via a socket connection. Using the send function. Pass the command you want to the server thru the Send function.
There are alot of Telent articles here so, do a search and take a look see.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi,
my list isn't behaving the way I want it to. I have the following code which I step through in the debugger.
<br />
std::list<int *> testList;<br />
int * one = (int *) 0x01;<br />
int * two = (int *) 0x02;<br />
int * three = (int *) 0x03;<br />
testList.push_back(one);<br />
testList.push_back(two);<br />
testList.push_back(three);<br />
one = two = three = NULL;<br />
three = testList.back();<br />
testList.pop_front();<br />
two = testList.back();<br />
testList.pop_front();<br />
one = testList.back();<br />
testList.pop_front();<br />
In the end I get all three int * variables to be 0x03 which is not what I intended with this code. And yes, I am trying to create a list of pointers because eventually it will be a list of pointers to a class representing an image which I don't want copied on each enqueue and dequeue operation.
|
|
|
|
|
I didn't notice when I pasted but the <int *> template didn't paste with my code. I do have it there:
std::list<int *> testList;
|
|
|
|
|
I see why the variables are all equal to three. Sorry, stupid question.
|
|
|
|
|
Replace all the pop_front() by pop_back() .
What you are doing here is reading the last element of the list then removing the first one. Then reading again the last (which is of course the same because you removed the first and not the last one).
Hope this helps...
|
|
|
|
|
give me a suggesstion to buy a best book for Embedded VC++,
How to start Pocket PC application development, for that i need to instal any software on the Pocket PC or not.
kindly give me a solution ASAP.
best regards
MohanRaj.K
to make communication between Server and Pocket PC through wireless(Wi-Fi), for that developing the front end application software by using VC++ in WinCE OS.
|
|
|
|
|
I have bought Pocket PC from hp that model no is hp iPAQ h6365, in that i need to develop the application to make wireless communication between server an pocket pc, server will transmit data that may be text file or Excell file, from that pocket PC application sholud encript that data and creata grphical format screens as well as window based screen like a VB.
In order to develop application i have selected Embedded VC++
Pocket PC OS is WindowsCE
My quitions is how can i implement my program into the Pocket PC, how start to develop an application.
to make communication between Server and Pocket PC through wireless(Wi-Fi), for that developing the front end application software by using VC++ in WinCE OS.
|
|
|
|
|
Go to the following site:
MSDN downloads[^]
download the emBedded Visual C++ 4.0 and also the Service pack 4.
Also you best get Active Sync, which eVC uses to initiate a connection with mobile devices.
Greetings,
Davy
|
|
|
|
|
Hello!
How can I determine the height in pixels of status bars? The GetSystemMetrics function seems to give many such values, but doesn't support status bars??
Best regards
|
|
|
|
|
|
Perhaps you could try getting the dimensions of the CStatusBarCtrl that is contained within a CStatusBar ?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
The size of a status bar is application-dependent. You'll need to take the height of the main window and then subtract other heights from it like caption, menu, non-client area, and border. There may be other values, too.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Get the window handle to the status bar's window.
Then can call GetWindowRect.
Take the height of the rectangle as the height of the status bar.
|
|
|
|
|
How can I get the handle?
I tried the following from my View-class:
<br />
CMyView::OnInitialUpdate()<br />
{<br />
...<br />
<br />
CRect rcStatusBar;<br />
<br />
CFrameWnd* pFrame = (CFrameWnd*) GetParent();<br />
CStatusBar* pStatusBar =<br />
(CStatusBar*) pFrame->GetControlBar(AFX_IDW_STATUS_BAR);<br />
CStatusBarCtrl& statusBarCtrl = pStatusBar->GetStatusBarCtrl();<br />
<br />
statusBarCtrl.GetWindowRect(rcStatusBar);<br />
<br />
...<br />
}<br />
But this leaves me with a CRect with the size of 0 height and 0 width...
|
|
|
|
|
These are all MFC Window objects. It is possible that during the OnInitialUpdate that the true 'window' have not yet been created?
You can check with:
::IsWindow(pFrame->m_hWnd)
and if that is not true, your windows don't exist yet, so all widnow rectangles will return empty rectangles.
You might have to investigate something like RecalcLayout and call it from some other location once the windows exist.
|
|
|
|
|
i had finished an application that communicate with server by web services. i programmed it by VC++.net 2003 on win2003. it's ok when setup on win2003 but not ok on win2000, when it ran on win2000, it could not get any data from web services(written by C#). My msi had included soap3_core.msm,msxml4sys32.msm,vc_user_mfc71_rtl_x86_---.msm,vc_user_stl71_rtl_x86_---.msm,vc_user_crt71_rtl_x86_---.msm.
Z.J.Chen @ CZoneSoft --http://www.cnblogs.com/babyblue
|
|
|
|
|