|
I have a dataset that I read from an xml file using
DataSet.ReadXml(fs);
I then add to the dataset and rewrite the xml file using the following:
DataRow newrow = mf.quotesDataSet.Tables["quote"].NewRow();<br />
newrow["thequote"] = quoteInput.Text;<br />
newrow["speaker"] = speakerInput.Text;<br />
newrow["origin"] = originInput.Text;<br />
newrow["image"] = "test.jpg";<br />
mf.quotesDataSet.Tables["quote"].Rows.Add(newrow);<br />
mf.quotesDataSet.WriteXml(fw);
It does add the data, however, it adds it outside the main xml hierarchy. For example, instead of:
<rss><br />
<channel><br />
<quote><thequote>text</thequote></quote><br />
<quote><thequote>text</thequote></quote><br />
<quote><thequote>new text</thequote></quote><br />
</channel><br />
</rss><br />
it writes to the file as:
<rss><br />
<channel><br />
<quote><thequote>text</thequote></quote><br />
<quote><thequote>text</thequote></quote><br />
</channel><br />
</rss><br />
<quote><thequote>new text</thequote></quote><br />
how do I make the added rows to the dataset write into the proper hierarchy?
|
|
|
|
|
<br />
#pragma check_stack(off)<br />
#pragma comment(linker,"/OPT:NOWIN98")<br />
#include <windows.h><br />
#include <shellapi.h><br />
<br />
#define mFunc(x) int __stdcall x(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)<br />
<br />
<br />
mFunc(IsTaskbarAutoHideOn)<br />
{<br />
APPBARDATA ABData;<br />
ABData.cbSize = sizeof(ABData);<br />
return<br />
SHAppBarMessage(ABM_GETSTATE, &ABData)<br />
& ABS_AUTOHIDE;<br />
wsprintf(data,"%d");<br />
return 3;<br />
}<br />
any idea why this won't return a value to mIRC?
also what function do i use to enable or disable it? thanks
PS: i'm kind of a newb, so try and use simple english :p lol
"Don't fight with idiots, first they pull you down to their level, then they smash you with their experience"
|
|
|
|
|
I have a need to changed the All Ways On top setting for the Windows Task Bar under program control. I have tried using SHAppBarMessage to Set State but it does not work. Has anyone done this and how?
|
|
|
|
|
Hi all,
I'm toying around with VS2005 Beta 2, recompiling one of my ongoing projects that contains ~300 .CPP files. Normally I use VC6 to work with this project.
I'm getting tons of warnings I wanna get rid of, namely C6054 ("string may not be zero-terminated") and C4996 ("function was declared deprecated"). For the most part, I'm getting these out of MS's own headers like tchar.h.
I need those headers but could do without those specific warnings (for now). I could "#pragma warning" them out before including the offending files, but I'd have to do this for nearly all of my 300+ CPP files; this is impractical for this project. I don't want to lower the warning level either for the entire project, because there are other warnings I actually do want to see.
How could I disable specific warnings, project-wide?
|
|
|
|
|
Put the #pragma warning in the stdafx.h file?
Daniel Desormeaux wrote:
C6054 ("string may not be zero-terminated")
That looks kind of wierd, how are strings to be terminated if not with a zero (NULL)? or are NULL and zero considered to be different in 2005?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
> Put the #pragma warning in the stdafx.h file?
I don't have one. This is a raw Platform SDK project that started off years ago with a totally empty file to which a main() function was added and then things evolved from there...
> That looks kind of wierd, how are strings to be terminated if not with a zero (NULL)?
For all intents and purposes, I think that particular message is intended to point out potential buffer overrun errors (eg, strcpy vs strncpy)...
|
|
|
|
|
Since the code that is being complained about is not yours, the #pragma suggestion might be your best bet. Read here for more.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello,
I believe that there was some define that turns all the deprecated warnings off. I think it was something like _NODEPRECATED or something. Try and look up de definition of the deprecated macro in VS2005. I'm sure that you can find it somewhere in the header files.
Blog[^]
|
|
|
|
|
Sounds promising--thanks!
|
|
|
|
|
Hi! Everyone...
I have two doubts. Please help me !!!
Can Multiple Instances created for a Static Library? If Yes, How?
I have got an idea of developing a Dynamic Library which uses a Static Libary, Can I do so for running Multiple Instances of that Static Library INDIRECTLY?
PLEASE HELP ME !!!
Thanks in Advance
R. Abdul Rahman
|
|
|
|
|
static libraries do not "run". they are collections of pre-compiled functions (and variables) that are copied into the DLL or EXE you link them to. each DLL or EXE gets its own copy of the functions that do not communicate, ever, with the static library itself.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thank you,
I have created a class which uses a Library Functions. The Library provider specified that is a Multi-Threaded DLL Library, But the extension is (.Lib)
Now my doubt is, If I create Multiple instances for MY class, the library will got shared or multiple instances will be created?
PLEASE HELP ME !!!
|
|
|
|
|
yes if that instances reside in the same process.
Multi-Threaded DLL Library means that runtime code is located in the DLL.
So if some other dll use Multi-Threaded DLL Library they will share the same runtime code.
Another reason to use DLL is memory allocation. If you have some DLLs that allocates memory from inside one DLL and that memory is deallocated by another dll such dlls should use Multi-Threaded DLL Library. Static library uses its own heap so if you deallocate memory inside dll that uses Static library and memory is allocated by another dll this can couse memory leaks and even crash.
That is true if you use memory allocation routines like new and delete.
|
|
|
|
|
How to change font while printing using MFC? I want to print different font in a page. I create new font befoe I use it. But it doesn't work.
|
|
|
|
|
Take a look at CDC::SelectObject().
|
|
|
|
|
How to rotate a GDI object in VC++ without using setworldtransform?
|
|
|
|
|
If it's a DIBSection( i.e. you have access to the bitmap bits ), then you can perform the rotate yourself on a new DIBSection ( seeing as a rotated image is bigger. )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How do you duplicate a file? Is there a windows API? Or do you just use CFile to read it in and create a new copy?
Thanks for the insight.
|
|
|
|
|
Try CopyFile or CopyFileEx
here is the description:
BOOL CopyFile(<br />
LPCTSTR lpExistingFileName,<br />
LPCTSTR lpNewFileName,<br />
BOOL bFailIfExists<br />
);<br />
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Thank you. That was right on the money.
|
|
|
|
|
In addition to what Tom said, I would also suggest looking at the MakeSureDirectoryPathExists function if you need to copy the file to a specific folder hierarchy.
(This function is in the dbghelp.dll, which you'll need to distribute depending on the target OS - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/makesuredirectorypathexists.asp)
Cheers,
Tom Archer - Archer Consulting Group
"Eat your brussel sprouts, Junior. There are starving Chinese children American programmers that would kill for that food!"
|
|
|
|
|
|
I have made one C++ DLL using VC++ 6.0 which has a function, in this function loadlibary function which open the WAB32.DLL file and at the end of function freelibrary function was used to destroy the instance of loadlibary.But when i call this function in VB frequenty it will return memory is full message. So How to destroy the instance of loadlibary from memory.
So please solve my problem as soon as possible.
|
|
|
|
|
Ashish Chauhan wrote:
But when i call this function in VB frequenty...
How are you doing this in VB?
Ashish Chauhan wrote:
...it will return memory is full message.
Have you Googled for the exact text of the message?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
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 " " ;
}
}
|
|
|
|
|