Re: Release Version problem
Using MessageBox I found the retCode. It is 0xEA. What does it mean?
Re: Release Version problem
1. Please, use Code tags!
2. What is VALUE_MAX_LEN? What is its value?
3. Read the documentation about CRegKey::QueryStringValue:
Quote:
Parameters
pszValueName
Pointer to a null-terminated string containing the name of the value to query.
pszValue
Pointer to a buffer that receives the string data.
pnChars
The size, in TCHARs, of the buffer pointed to by pszValue. When the method returns, pnChars contains the size, in TCHARs, of the string retrieved, including a terminating null character.
Re: Release Version problem
Quote:
Originally Posted by
shjdr7
Using MessageBox I found the retCode. It is 0xEA. What does it mean?
From MSDN:
Quote:
Return Value
If the method succeeds, ERROR_SUCCESS is returned. If the method fails to read a value, it returns a nonzero error code defined in WINERROR.H. If the data referenced is not of type REG_SZ, ERROR_INVALID_DATA is returned. If the method returns ERROR_MORE_DATA, pnChars equals zero, not the required buffer size in bytes.
Re: Release Version problem
Quote:
Originally Posted by
shjdr7
So I enabled debugging in the release version. But in the release version when I press F10 it is skipping
some lines!
That is because you have optimizations turned on. Turn off the optimizations in release mode and rebuild your application if you want to debug a release build and have the source code match the actual instructions that are executed.
Regards,
Paul McKenzie
Re: Release Version problem
Thank you. The correct code was
ULONG nChars = sizeof(value);
Why it was working in debug version is surprising me.
Re: Release Version problem
Quote:
Originally Posted by
shjdr7
Thank you. The correct code was
ULONG nChars = sizeof(value);
No, it is wrong!
Why don't you read the documentation? :thumbd:
Again, from MSDN:
Quote:
pnChars
The size, in TCHARs, of the buffer pointed to by pszValue. When the method returns, pnChars contains the size, in TCHARs, of the string retrieved, including a terminating null character.
But sizeof returns the size in bytes!
So the correct code would be
Code:
ULONG nChars = sizeof(value) / sizeof(value[0]);
or just
Code:
ULONG nChars = VALUE_MAX_LEN;
Re: Release Version problem
Quote:
Originally Posted by
shjdr7
Thank you. The correct code was
ULONG nChars = sizeof(value);
Why it was working in debug version is surprising me.
You were passing a pointer to an uninitialized variable. In a debug build, the variable's value is initialized to 0, but in a release build the variable really remains uninitialized. It's value will be whatever happened to be last written to that particular piece of memory.
Re: Release Version problem
Quote:
Originally Posted by
D_Drmmr
You were passing a pointer to an uninitialized variable. In a debug build, the variable's value is initialized to 0,
Isn't it initialized to something like 0xcdcdcdcd ?
Re: Release Version problem
I agreed. My code was wrong again.The correct code was
ULONG nChars = VALUE_MAX_LEN;
Thank u, again