|
I want to list all sub-keys under a key. In my test I have two sub-keys. I open my key with ::RegOpenKeyEx() and then I put zero into first call for ::RegEnumKeyEx() . I call it again until it does not return ERROR_SUCCESS . This is my code:
HKEY hKey;
CHAR achKey[MAX_KEY_LENGTH];
DWORD i = 0;
if (::RegOpenKeyEx(HKEY_CURRENT_USER, REG_MAJOR_KEY, 0,
KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
{
while (::RegEnumKeyEx(hKey, i++, achKey, &cbName, NULL, NULL, NULL,
&ftLastWriteTime)) == ERROR_SUCCESS)
print("Found %s", achKey);
RegCloseKey(hKey);
}
The problem is it finds one key but not the other. Can anyone tell me where I am wrong please? Thank you.
|
|
|
|
|
Shouldn't you be checking against ERROR_NO_MORE_ITEMS instead?
while (::RegEnumKeyEx(hKey, i++, achKey, &cbName, NULL, NULL, NULL, &ftLastWriteTime) == ERROR_NO_MORE_ITEMS)
...
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
Hello,
MFC CString has the += operator.. When dealing with char's how can one achieve the same thing?
I need to keep adding the contents of one char to the other while in a loop.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Use strcat() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks David!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
One more question.. You answered my question correctly but I just realized that I was asking the wrong question.. Given the following code, can you give me any hints on how I can accomplish what I'm trying to do?
s_recv sRecv;
int nRecvSize = 0;
char outBuff[sizeof(s_recv)];
while(nRecvSize < sizeof(s_recv))
{
char inBuff[sizeof(s_recv)];
int nRecv = recv((SOCKET)wParam, inBuff, sizeof(inBuff), 0);
TRACE("Received %d of %d\n", nRecv, sizeof(s_recv));
if(nRecv == SOCKET_ERROR)
{
TRACE("MainFrm Recv Error %d\n", WSAGetLastError());
break;
}
else
{
if(nRecv == 0)
break;
strcat(outBuff, inBuff);
nRecvSize = nRecvSize + nRecv;
}
}
memcpy(&sRecv, outBuff, sizeof(outBuff));
Thanks for all the help...
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote:
...can you give me any hints on how I can accomplish what I'm trying to do?
Assuming I knew what it is that you wanted to accomplish.
RobJones wrote:
strcat(outBuff, inBuff); // This doesn't work how I want it to..
So what is it doing instead?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
The structure is like this...
struct s_recv {
int nTag;
char sTagMsg[256];
char sMsg[3072];
};
When I do the receive sometimes I dont receive the whole structure just a peice of it.. So I'm trying to store what I have received in a char and then keep appending the data until all the data is received..
Here is a output of the strcpy...
The inBuff contains..
[0] -75 'µ'
[1] 6 ''
[2] 0 ''
[3] 0 ''
[4] 110 'n'
[5] 111 'o'
[6] 110 'n'
[7] 101 'e'
[8] 0 ''
[9] -51 'Í'
etc.......
This is fine.. But when I do the cat..
the outBuff looks like this...
[0] -75 'µ'
[1] 6 ''
[2] 0 ''
[3] 0 ''
[4] 0 ''
[5] 0 ''
[6] 0 ''
[7] 0 ''
[8] 0 ''
[9] 0 ''
etc......
I think I need some way of doing a memcpy that appends instead of strcat...
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote:
I think I need some way of doing a memcpy that appends instead of strcat...
You are correct. This is because the data you are receiving may have embedded '\0' characters, of which strcat() uses and memcpy() does not.
Try something like:
int nOffset = 0;
...
memcpy(outBuff + nOffset, inBuff, nRecv);
nOffset += nRecv;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
YOUR THE MAN!
Thanks for all your help!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I was passing through revolving door the other day, and i stopped half the way and hold the door real tight so it stopped revolving. the door slammed onto the face of guy behind me who was passing through the door too.
nothing is impossible..
|
|
|
|
|
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Have you ever looked at the PCL output from Word? You don't see complete words all the time. You see the PCL doing adjustments in the Horz direction with certain characters. Why is it doing that? Could it be that it is adjusting the Horz position due to the printer? Could it be that it is doing it because of the font? How is it deciding when to do the adjustment?
Fonts are driving me nuts! When I use the CRichEditCtrl’s FormatRange, it puts out a single string. I create a text box in Word, put the same text in and I notice that it breaks it up. Now I’m wondering why?
[EDIT]
AND, it doesn't look the same! The printed lenght (in inches) are not the same but have the same characters exactly! WHY? <- Pulling hair out!
[END EDIT]
I really do need some insight in outputting fonts to the printer. Something is going on that I’m in the dark about and I need some help big time!
Thanks to any who respond.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
It might well be that the PCL spit out by Word reflects the way that they are adjusting intercharacter spacing to improve kerning in a word, and in some cases for things like text justification, this is practically mandatory. If you want to know much much more about fonts, printing, and the rest of the GDI stuff, get yourself a copy of the Feng Yuan GDI book. It's worth every penny(or other currency of your choice).
I contracted at Serif once upon a while, and we used info like the ABC tables from fonts to alter output, and it really does make a difference.
Steve S
|
|
|
|
|
Thanks Steve,
(Quick response too! ) I currently have Fengs book and have tried some of examples in the code that I'm doing. I adjusts it too much the other way! Trying to make a WYSIWYG application is not the easiest thing at all.
You by chance don't have any examples that I can sneak a peak at do you?
Larry
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Not without enraging at least half a dozen lawyers!
You need to check his web site for errata (I think there's one in there from me!), and be aware of using reference (or em square?) fonts to derive size information. Generally, his stuff is fine for all but the pickiest of users, although I have had to do some work on things like breaking strings into paragraphs, lines, and words for formatting purposes.
More recently I've worked with FormatRange, having needed RTF editing capabilities for WP like behaviour, and that was an education in itself!
Steve S
|
|
|
|
|
Quote
Not without enraging at least half a dozen lawyers!
Well, we wouldn't want that now would we? I will have to see if I have the URL to his web site. Also, you don't have any test programs when you were learning hanging around do you? Those would do.
Also, I'm using his "Text.exe" example where you can insert the font and point size to get information about that font. I used the equaion to convert the point size into the logical:
Logical = ( point * LOGPIXELSY ) / 72
and found out about the size to enter. Using this information, I'm seeing what happens. The first section adds up correctly. The next character is on smaller, have not done the rest yet...
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Well, I wouldn't. Some of my best clients are lawyers...
I'll dig around my old backup CDs and see what comes out of it. Have to admit I skimmed through some of his examples, because they weren't relevant to what I needed, or in some cases, I already knew what I was doing (which, it has to be admitted, doesn't happen often!).
Good luck
Steve S
|
|
|
|
|
HUMMM.
Using Feng's example "Text.exe" I set the font to 62 (the size on the printer in devics units) and I added up the character width for "RIPTION" in bold/italic and this value was 341. I then used the ABC character widths adding up the values and came up with 357! I checked it several times and it was the same.
I wonder if the amound (difference) gets to be too big, that it adjusts?
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Doesn't surprise me, somehow. This might well account for layout differences in WORD. Although 16/300 of an inch isn't much, over the course of a full line it would increase enough to be noticeable.
Steve S
|
|
|
|
|
Except it is doing it often. I have another that has lots of spaces and it is doing it with the spaces. I'm going to analyis to see where it is doing the adjusting and why. Will post the results.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
Steve,
I think I have found it. When I get the sum (from Feng's reference font) and the actual sum of the fonts being calculated, it seems that when the difference gets bigger than +/-1 it adjusts. I printed out the width being calculated in his KTextFormator::TextOut method along with the actual width from GetCharWidth32. When the sums are within +/-1, there is no adjustment, once it goes over that range it adjusts the output position.
Now I need to see if I can implement this and see if it works...
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|
|
I've now stopped wondering why anything works, and also why it doesn't.
Having beaten my head against a brick wall by trying to write a SOAP intercepting ISAPI extension according to the spec provided by one of my temporary colleagues, we're now trying a different approach. I only come to CP as therapy - a kind of schadenfreude I suppose, although it's rewarding to answer or join in another coder's problems and get a result.
Steve S
|
|
|
|
|
Well, kiss my grits! It didn't work! It still spreads out. I still think the best way is to let the rich edit output itself, problem is that I also have other graphic objects that are to be drawn and I think the problem is switching from someother mapping mode back to text.
Larry J. Siddens
Cornerstone Communications
TAME THE DOCUMENT MONSTER
www.unifier.biz
|
|
|
|