|
Even if you count them yourself, so what? You still can't pass, say, a 1 for a %s parameter and not have it fail.
I have a safe format function which is basically the following (with more error and exception processing, but this gives the gist):
__try
{
return _vsnprintf(pBuffer, bufferLen, pFormat, args);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
Copies raw format string into buffer
}
|
|
|
|
|
You say that this is YOUR function to post an error message, thus it is assumed that it is YOUR code that is calling this function. I would suggest that you examine all calls to SetErrorInfo in YOUR code to insure that they supply parameters for each '%' in the format string.
There is not a built in way to check the number of arguments pushed on the stack for a call.
There is a messy way to do this, but it involves modifying all code that calls SetErrorInfo, and this amounts to the same effort (only more so) as to examine all the calls to SetErrorInfo. You could drop into ASM and push a flag value (__ASM mov eax,0x012345678 __ASM push eax) just before making the call to SetErrorInfo, make the call, then erase the flag upon return by dropping into ASM again (__ASM add esp,4). Inside SetErrorInfo you could examine the stack by dropping into ASM and check if the flag value immediately followed the format or was found too close to the format argument for the number of '%' characters in the format string. First you have to verify that a format string has actually been passed (and not a NULL argument), then that the string contains % characters, etc, etc, etc. Messy, messy, messy! Just examine all calls to SetErrorInfo.
Dave.
|
|
|
|
|
CSting strid = m_strStringArr.getat(i);
T("INSERT INTO tablename (setid) VALUES('strAnsi')");
This is my query and i get table field and its value at runtime.So how to insert this value.any idea about it..means Setid and stransi i get at runtime..
modified on Monday, September 14, 2009 6:37 AM
|
|
|
|
|
Use CString::Format[^] to create the string.
CString cs;
cs.Format(_T("INSERT INTO tablename (%s) VALUES('%s')"), setid, strAnsi);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
It Works..
Thanks Superman
|
|
|
|
|
But after set this data to fields,every fields ti goes into new line.i dont want this.I want after new line it goes to next line or next record.So how to solve this problem..
|
|
|
|
|
When strAnsi has _T("aaa\nbbb\nccc") then want to make 3 records?
Do you mean like this?
If then, you must split strAnsi at first and make and execute sql 3 times.
For example;
TCHAR* strData = strAnsi.GetBuffer(-1);
TCHAR* pToken = _tcstok(strAnsi, _T("\n"));
while (pToken) {
CString sql;
sql.Format(_T("INSERT INTO tablename (%s) VALUES('%s')"), setid, pToken);
}
strAnsi.ReleaseBuffer();
Well, I dont feel good VALUES('%s') in above sql because of string
escaping issue or SQL-injection problems.
I usually use prepared statements or parameterized query for this purpose.
|
|
|
|
|
Do you really mean this
CString strTable = _T("MyRuntimeValueForTable");
CString strData = _T("MyRuntimeValueForData");
CString strQuery;
strQuery.Format(_T("INSERT INTO %s VALUES ('%s')"), strTable, strData);
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi,
please anyone help me in programming ptz camera query and response commands. pan tilt zoom functionalities are all done but I dont know how to get the angles from ptz camera.I tryed to give the query command and response but have some problem and I dont know how to use this commands of protoocol in c++.. I am using pelco D protocol. please help 
|
|
|
|
|
Hi
How to cut rectangles in images ..in dialog based application
thanks and regards
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
See here.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks 4 ...your replay
CImage _cImage;
_cImage.Load(_T("D:/2009ga.jpg"));
CRect rect(9175,631,10563,65);
_cImage.Draw(NULL,rect);
_cImage.Save(_T("D:/tct.jpg"));
but the result showing the same image of 2009ga.jpg
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
Hi..
New in c++ application... Now i need play video.. i got Vlc code from corresponding VLC Site.. which have c and c++ code ... I want run that code ... How can i run that project... Which Software we use...
Thanks
|
|
|
|
|
Have a look at [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
anishkannan wrote: Hi..
New in c++ application... Now i need play video.. i got Vlc code from corresponding VLC Site.. which have c and c++ code ... I want run that code ... How can i run that project... Which Software we use...
Thanks
The only response I could think of:
Liquid-Nitrogen[^]
|
|
|
|
|
Outstanding!
Just to let you know where the 5 is from....
|
|
|
|
|
HI all
I am using vs2005, I need to develope application in vc++ for retrivin data from and xml.
can anyone suggesst some ideas.
|
|
|
|
|
Here on CP there are a lots of articles about XML parsers -> here[^]
Regards
Nuri Ismail
|
|
|
|
|
No, useless.
Simply use built-in Win32 XML apis (COM, SAX, and others)
Tons of samples in MSDN in C and C++
|
|
|
|
|
kilt wrote: No, useless.
I don't think so! These articles, from the link I gave, were (and still are) very useful for me!
The next time think again before determining the hardworking people's great contributions (in this case - over 30 articles about XML, here on CP) as useless!!!
You might be a very "constructive" person! I can see your "huge contribution" in your posts[^].
Regards
|
|
|
|
|
Nuri Ismail wrote: You might be a very "constructive" person!
That's the last adjective I'd use to describe him.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Absolutely!
I saw a great "effort" and "clarity" in his posts, so I couldn't resist to be a little bit sarcastic.
Regards
Nuri Ismail
|
|
|
|
|
kilt wrote: Simply use built-in Win32 XML apis (COM, SAX, and others)
These are as built-in as the CP articles.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello Coder
Am new in graphics
can u plz help me to resize .bmp image by factor 2 or 3 or 4.
|
|
|
|
|
There are several ways.
My DLL [^], for instance, provide resizing without too much quality loss.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|