Problem with != operator of CString
-
The following is the code fragment which I used in my application, CStringb csFilePath = _T("C:\\MyFolder\\"); if(csFilePath != "\\") { DWORD dwError = GetLastError(); } And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008. But in VC6.0, there is no such problem, the error code i am getting is 0.The application is with UNICODE supported. Please help me to find out the cause of this problem. :(
Thanks & Regards VIJITH VIJAYAN
-
The following is the code fragment which I used in my application, CStringb csFilePath = _T("C:\\MyFolder\\"); if(csFilePath != "\\") { DWORD dwError = GetLastError(); } And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008. But in VC6.0, there is no such problem, the error code i am getting is 0.The application is with UNICODE supported. Please help me to find out the cause of this problem. :(
Thanks & Regards VIJITH VIJAYAN
VIJITH VIJAYAN wrote:
if(csFilePath != "\\")
this should probably be
if(csFilePath != _T("\\"))
:)
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] -
VIJITH VIJAYAN wrote:
if(csFilePath != "\\")
this should probably be
if(csFilePath != _T("\\"))
:)
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 for the quick response .But at the compilation time this code didnt shown any errors or warnings . Do have any idea ,why it had happened like this ?
Thanks & Regards VIJITH VIJAYAN
-
Thanks for the quick response .But at the compilation time this code didnt shown any errors or warnings . Do have any idea ,why it had happened like this ?
Thanks & Regards VIJITH VIJAYAN
Because the
CStringT ==
operator is overloaded to handlePCYSTR
.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] -
The following is the code fragment which I used in my application, CStringb csFilePath = _T("C:\\MyFolder\\"); if(csFilePath != "\\") { DWORD dwError = GetLastError(); } And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008. But in VC6.0, there is no such problem, the error code i am getting is 0.The application is with UNICODE supported. Please help me to find out the cause of this problem. :(
Thanks & Regards VIJITH VIJAYAN
VIJITH VIJAYAN wrote:
And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008.
Possibly because that's the last value that was set (with
SetLastError()
). In other words:SomeWindowsFunctionThatFailsWithCode122();
CString csFilePath = _T("C:\\MyFolder\\");
if (csFilePath != _T("\\"))
{
DWORD dwError = GetLastError();
}If nothing calls
SetLastError(0)
, then its internal value will stay122
."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