|
Can't you use CString.Format, or an ostringstream to build the string with the \x values in it ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I tried using format(), but \x requires a number after it.
Anyway I ended out with the following:
<br />
CString sHeader;
int nHigh; <br />
char sHigh; <br />
nHigh = strtol(sHeader.Left(2),NULL,16);<br />
sHigh = nHigh;
Seems to work fine so far.. Thanks for your help.
BW
"Gandalf. Yes. That is what they used to call me. Gandalf the Grey. *I* am Gandalf the White."
- Gandalf the White
|
|
|
|
|
Hi.
I am working on a project that includes downloading data from webservers. There is a problem. Some webservers rejects the program request for data. In one example, the webserver responded with an error that the request was ignored because the client (program) is trying to access the data from another server. In terms of web browsers, this is like clicking on a link at www.google.com to download data from www.gamespot.com.
To my understanding, the server is incorrect because the program is communicating directly to the server just as a web browser does. I would like to know how do web server such as the example know where the client originally found the link to the data?
In the example above, is there any HTTP 1.1 code that I need to add to the request so that the server to process the request?
Thanks,
Kuphryn
|
|
|
|
|
This is from RFC 2616 which is HTTP 1.1.
Take a look at section 14.23 and 14.36. I think 14.36 is the key here. If I remember correctly, many servers use the "referer" field to know if content such as jpgs are being requested from pages hosted locally or from general requests from other websites. Lots of photo posting services do stuff like this so you can't store 1000 images on their site and then reference them from EZBoard.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
Okay. I have tried both solutions, but none worked. Here is an example of the request.
-----
/GET http://visualparadox.com/images/no-linking-allowed/coloroncall800.jpg HTTP/1.1
Host: visualparadox.com
Referer: http://visualparadox.com/wallpapers/coloroncall.htm
Accept: text/plain, text/html
Accept-Language: en-us
Accept-Encoding: gzip
Connection: Keep-Alive
-----
Again, the request above does not work. Here is one website I tested use to test the request.
http://visualparadox.com/wallpapers/coloroncall.htm
http://visualparadox.com/images/no-linking-allowed/coloroncall800.jpg
Kuphryn
|
|
|
|
|
I am using the Create() function to create a bunch of CEdit s in a CFormView derived class.
my problem is that as i tab through the fields they are not selecting the text in the field. they normally automatically highlight the text when the field gains focus.. it was the other day, but now its not.. any ideas?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
dazinith wrote:
it was the other day, but now its not
What was different the other day? Has someone else added an OnSetFocus handler? It may help to compare your source file with a version from when it did work. Hopefully you can do that and see what changed.
Regards,
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|
|
For an application we are developing we found that the first operation was taking an extremely long time on Windows XP. Initially we though it was a problem with our program, but later we found that even Explorer showed the same slowness.
Just reboot to XP, right clk on the large file and take Properties. The properties box won’t come for several seconds and the larger the file, the longer will the delay be. Google searches showed that there are several others who have faced similar issues. What is strange is that this is only for the first read, for further reads this problem is not there.
In our application the size of the file might go up to 1 Gb or above and might even be read on an USB device. In such a situation any extra delay is really an absolute problem for us. In fact we also tried taking the cmd prompt and renaming the file. The first rename took several seconds for a 10 Mb file, but further renames were immediately done.
We tried to open/close the file from another app, seek to end of file, read from the file, get file size etc… but all that still does not prevent the slowness when you simply try to take file properties from explorer. Is this an XP issue, if so is this a known bug? Any idea what really happens? Any fix?
Two very important points, this bug seems to be random (but only on XP, never happened on W2K). Sometimes the first and following operations work very well without delay. And secondly, this seems to concern only exe file (even if the extension is different).
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Um... doesn't that make sense ? The bigger the file, the longer it takes to parse, but Windows also builds a cache ?
XP is the first OS that natively looks for .NET executables and handles them differently. Might that be part of your problem ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Nish - I don't think it's anything specific to Windows XP - I've noticed the same phenomenon on Windows 2000, especially with files on network drives... Think about it, for some files where there's more than just size & file times (like executables, where the version is shown in properties), Windows pretty much has to read in the whole file to get at the relevant bits...
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Alot of our customers have reported approx. the same thing... I heard something that it should be fixed in SP1 but I haven't got this confirmed.
Can't even confirm the "bug" since I don't run XP myself so please consider this second hand info (at best).
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
I'm looking for some inline assembly for a couple of simple things:
1. to invert all bits in a row of bytes. the typical C way is
BYTE *pIn...;
for (UINT x=0;x < bytes;x++)
{
pIn[x] = ~pIn[x];
}
i think this can be improved by doing the inverts a DWORD at a time, and by accounting for DWORD-alignment of the buffer. (i think this because that's what MS's memcpy and memcmp do. i just don't know enough assembly to do what i need)
2. logical-OR two equal-sized BYTE buffers
for (UINT x=0;x < bytes;x++)
{
BYTE a = pInA[x];
BYTE b = pInB[x];
pInA[x] = a & b;
}
again, i think this could be improved by processing 4 bytes at a time and by accounting for DWORD alignment.
anyone?
-c
I'm not the droid you're looking for.
|
|
|
|
|
And why exactly do you need to do it in assembly?
The mistakes made in this API make me realise that Microsoft has become big enough that it can shelter morons. If anyone working for me wrote anything this bad and tried to release it, I would kill them and display the body as a warning to the rest of the team. - Christian Graus about C# - GDI+
|
|
|
|
|
didn't anyone ever tell you it's not polite to answer a question with a question?
i want to do it in assembly for the same reason MS has all of its low-level string and memory function in assembly - performance.
-c
I'm not the droid you're looking for.
|
|
|
|
|
Before you start getting into assembler, the first thing I would do would be to modify the code to process the bytes in 4 byte blocks (ULONG) and then any remaining 0-3 bytes.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
but wouldn't be even nicer to have the bulk of the process operating on dword-aligned dwords, instead of just running down an array of non-aligned dwords ?
-c
I'm not the droid you're looking for.
|
|
|
|
|
Yeah, the alignment can be a big problem. Routines such as memcmp check first to make sure the data is aligned.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I'm sure it could be written better, and it doesn't handle DWORD alignment, but it will do the trick. For more information on the Intel instruction set:
http://www.intel.com/design/pentium4/manuals/245471.htm[^]
void Invert( unsigned char * p_pucData, unsigned long p_ulLen )
{
__asm
{
pusha
mov ecx, p_ulLen
mov ebx, p_pucData
head:
cmp ecx, 4
jle tailbytes
not dword ptr [ebx]
sub ecx, 4
cmp ecx, 0
je end
add ebx, 4
jmp head
tailbytes:
cmp ecx, 0
je end
not byte ptr [ebx]
add ebx, 1
sub ecx, 1
jmp tailbytes
end:
popa
}
}
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
just FYI, this takes less than 15% of the time of the first invert loop i posted:
int z;
BYTE *pb = pBuf;
UINT32 uLeadUp = (DWORD)pBuf & 0x03;
for (z=0;z < uLeadUp;z++)
{
*pb = ~(*pb);pb++;
}
uLen-=uLeadUp;
UINT32 dwords = uLen / 4;
UINT32 leftovers = uLen % 4;
DWORD *p = (DWORD*)pb;
for (z=0;z < dwords;z++)
{
*p = ~(*p);
p++;
}
pb+=4;
for (z=0;z < leftovers;z++)
{
pb[z] = ~pb[z];
}
-c
I'm not the droid you're looking for.
|
|
|
|
|
I just ran some tests, here are the results:
My Machine:
2GHz Pentium 4
512 MB Ram
Data: 180MB char array.
Test: Bitwise NOT the contents of the array 100 times, alternating between the assembly version and the C++ version.
Debug build:
C++ Version:
445 ms average.
Assembler Version:
285 ms average.
Release Build:
C++ Version:
268 ms average.
Assembler Version:
284 ms average.
I think the most significant optimization (from your original sample) is copying 32 bits at a time, rather than 8 bits at a time, but surely the alignment helps.
It also appears that the optimizer is definately your friend!
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
It also appears that the optimizer is definately your friend!
About a month ago, someone posted a speed fix for a strxxx routine. I thought the enhancement was cool, but really didn't think it would be better than the MASM strxxx routine in CRTL.
I was wrong.
My bet is that many of those old strxxx MASM routines haven't been reviewed for performance on newer machines. A lot has changed.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
My bet is that many of those old strxxx MASM routines haven't been reviewed for performance on newer machines. A lot has changed.
Imagine how much has changed even in just the last 4.5 years since VC6 was first released. I would not be surprised at all to find that those old asm routines need a bit of review.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
I'm not an assembly geek, but did you consider
just assembly stepping into memcpy, copying their
code and modifying to to do whatever particular
operation you need? It should just involve replacing
a MOV instruction with an XOR or OR instruction.
Oh, on other thing, if you are going for fast
performance, I believe the special MMX instructions
of the Pentium processor can do this sort of stuff
really fast (obviously you'll have to check processor
version and provide an alternative for processors
without those instructions.)
|
|
|
|
|
I'm currently working on an MDI application that has dockable toolbars and a child window (view). I want to make a menu item that allows me to return the windows & toolbars to their initial position. I am able to place the toolbars successfully via docktoolbar(), but i cannot recall how to handle the child window. I would like to capture the window's position during/just after it's creation, and upon the appropriate menu call, restore that position. I've looked into Get/Set-WindowPlacement() but i'm very unclear on it's usage. Any advice would be appreciated, code is especially helpful.
I was also wondering how i can call the built in functionality from the window->tile menu command that tiles your child windows (from within my code at runtime).
Thanks
Jeff Rothenberg
Project Engineer
Vector CANtech, Inc.
|
|
|
|