|
Hadi_Rezaie wrote:
But now, i want to know Did you switch on it ?
Do you use C++ .NET instead of VC++ 6.0 ?
What's your programming language, right now ?
No, no and (the VC6 supported subset of) C++.
|
|
|
|
|
I'm still using VC++ 6.0 for my commerical work. I've just got too much time and code invested to change over yet.
I'm playing with VC7 and C# but haven't used them to make money yet. I'll have a look at the Everett release to see if it is worth the time and money to swap to VC7.
Michael
Programming is great. First they pay you to introduce bugs into software. Then they pay you to remove them again.
|
|
|
|
|
Hi guys,
I've problem reading a binary file, however it's successful in reading non-binary files such as text/wri files.
Specifically, the buffer reads NULL bytes and gives me ASSERT(lpBuf != NULL) from filecore.cpp, line 243. But, why is this just happening for binary files and not for the non-binary ones? I'ev tried the c runtime function fread() and it fails on the 2nd attempt of the loop yielding some 9 odd bytes even when reading large files (400kb).
This is the code:
CFile pFile (sFilename, CFile::modeRead);
int iReadSize = 0;
while(true){
iReadSize = pFile.Read(pBuf, 4096);
if(iReadSize == 0)
break;
else{
//my processing goes here
}
}
pFile.Close();
Any suggestions please?
Thank you.
|
|
|
|
|
That code looks ok except for pBuf. The ASSERT(lpBuf != NULL) indicates that you aren't initializing pBuf. Can you post the rest of the code?
Todd Smith
|
|
|
|
|
Hi Todd;
void MyClass::Read(CString sFilename)
{
BYTE *pBuf = new BYTE[4096];
CFile pFile (sFilename, CFile::modeRead);
int iReadSize = 0;
while(true){
iReadSize = pFile.Read(pBuf, 4096);
if(iReadSize == 0)
break;
else{
//my processing goes here
}
}
pFile.Close();
}
This is all there's to it. But, it works only successfully to .TXT/WRI files and not the binary. I am very parnoid about the BYTE buffer. You think the buffer being a BYTE has anything to do with it? I've tried all versions of read out there... <_read(...) and fread(...)>, and I've also tried the CHAR buffer instead for the BYTE buffer.
Let me know please.. thanks.
Jey
|
|
|
|
|
First off you should probably change that to
if (iReadSize <= 0)
break;
Don't forget to call delete on pBuf when you're done
delete [] pBuf;
You might try adding the share flag
CFile pFile(sFilename, CFile::modeRead | CFile::shareDenyWrite);
If you're getting ASSERT(lpBuf != NULL) then that means that you're doing something to pBuf in your processing stage. If you step through your code you might see that the first Read is successful and that the second Read is where your code is failing because pBuf is now 0.
BYTE is fine. It's the same as
char* pBuf = new char[4096];
Todd Smith
|
|
|
|
|
There are two types of class declarations in managed c++. __gc and __value.. i understand the difference between the two and I do not need a detailed explanation of either, but am unsure of when __value should be used. They say that __value is more efficient because it doesn't go on the clr (common language runtime heap) and doesn't have to dereferenced. In support of the __gc declaration, all objects are pointers to memory locations and must be dereferenced. The advantage of using __gc is that it uses visual c++.net's ability to garbage collect when the object goes out of scope. Am i correct in saying that the __value type does not take advantage of this feature? Also, in the opinion of managed c++ developers, would you all say that it is in the spirit of visual c++.net to use the reference type (__gc) over the value type (__value)? or have the experienced developers in this forum found uses for both in the .net world? Thanks!
~a confused developer
xai
|
|
|
|
|
Hi,
In a dialog box I am having two sets of radio buttons, in separate group boxes, but then they are all behaving the same...How do I make them behave separately.
I am a beginer and this is a big doubt for me. Pls help
Arthi
|
|
|
|
|
In resource editor set Group flag to first radio button in each group (make sure that they are in in good order in tab order)
Pavel
Sonork 100.15206
|
|
|
|
|
You need to set up group flags. You can do this programatically or if your using the resource editor you can set it in the properties. Just set the first radio button in each set of two with a WS_GROUP attribute.
Regards,
Brian Dela
|
|
|
|
|
Hi!
currently I'm programming an app that sends packets to (game)servers. Some packets look like this:
"\x12\x02trb2" , which means that they contain hexadecimal values.
If I define them in my program like this:
LPCTSTR PACKETS[NUMPACKETS] =
{
(...)
"\x12\x02trb2"
};
they get sent correctly. But I want my program to be more dynamic and let the user specify own packets that he wants to send to a server.
Of course, when the user types "\x12\x02trb2" into an edit box the packet will not be sent hexadecimal but as a complete string.
So I tried to replace the most important escape sequences in the edit box like this:
string.Replace("\\0", "\0");
string.Replace("\\t", "\t");
string.Replace("\\x", "\x");
string.Replace("\\n", "\n");
string.Replace("\\r", "\r");
All lines conpile fine, except the 3rd one. The compiler error is (translated from german):
error C2153: Hexadecimal constants need to contain at least one hexadecimal number
Does anybody know how I can get this to work?
thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
\x means nothing, \x12 is a character encoded with 12. You need to replace "\\x12" with '\x12'.
Pavel
Sonork 100.15206
|
|
|
|
|
thanks...how many numbers may follow after \x?
I will write my own parsing routine then
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Two. I'm not sure how's with it in UNICODE strings, but if I remeber it good, it's done using two following \x with two digits.
Pavel
Sonork 100.15206
|
|
|
|
|
Currently I'm writing a parser, but I have one problem:
if(d1 != -1 && d2 != -1)
{
numbers.Format("%i%i",d1,d2);
replacechar.Format("\\x%i%i",d1,d2);
CString digits = string.Mid(findx+2,2);
int iDigits = atoi(digits);
newchar.Format("%x",iDigits);
string.Replace(replacechar, newchar);
}
replacechar is \x12 , this is correct.
But now I need to convert it to hexadecimal:
iDigits is 12 , this is correct as well.
But newchar.Format("%x",iDigits); doesn't convert it correct into hexadecimal, since I don't get any answer from the server.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You are treating the hex number like a decimal one in atoi.
You need to convert it to decimal instead - then you get the needed character code.
Pavel
Sonork 100.15206
|
|
|
|
|
Could you tell me how to do it? I've never done it before
thanks
modified 12-Sep-18 21:01pm.
|
|
|
|
|
int res;
sscanf("12","%x",&res);
Pavel
Sonork 100.15206
|
|
|
|
|
well ok, I have converted it to my needs:
<br />
int res;<br />
sscanf(digits,"%x",&res);
Where do I put this line in my sourcecode and what shall I do with the result "res"?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
str.Replace(replacedstring,CString(TCHAR(res));
Pavel
Sonork 100.15206
|
|
|
|
|
|
My pleasure. Killing time during some boring backup and install job at CP
Pavel
Sonork 100.15206
|
|
|
|
|
Gregor S. wrote:
string.Replace("\\x", "\x");
The problem is that "\x" by itself in code is illegal since it is meaningless. You'll need to use Find("\\x") to get the location of a "\x" sequence, then parse the following characters (I think it's 2 chars max, check MSDN to be sure), then replace the whole lot with one byte. So the four byte sequence "\\x12" would become one 0x12 byte.
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
For WNDCLASS STRUCTURE if i want my window to have blue color.what should i do.
Can i use colorref to pass value to getstock object.
wndclass.hbrbackground=Getstockobject()
|
|
|
|
|
If you want a blue background use this:
wndclass.hbrBackground = RGB(0,0,255);
-Dominik
|
|
|
|