|
|
|
|
HOWTO: Iterate values/data inside a registry section?
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
DWORD status;
HKEY hKey;
DWORD dwIndex=0;
status=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Whatever\\Key",0,
KEY_ALL_ACCESS, &hKey);
if (status != ERROR_SUCCESS)
do {
status=RegEnumValue(hKey, dwValue,
dwIndex++;
} while (dwIndex != ERROR_NO_MORE_ITEMS);
RegCloseKey(hKey);
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi
if i allocate 2 new char arrays like:
char *pChars1 = new char[8];
char *pChars2 = new char[10];
can i be SURE (i.e. nothing other may happen) that when i use pChars1[8] get the first char of the second array (= pChars2[0])?
For example think of a string which is 7 chars long. Then i set pChars1[7] non-NULL. Then a string-read at the start of pChars1 would give the string consisting of the first and the second array?
If this is not possible, is there a compiler-switch to make this work?
Thanks
Dominik
|
|
|
|
|
No way, no how. Instead you'd need to do this:
char * pChars1 = new char[18];
memset(pChars, 0, 18);
char * pChars2 = pChars1+8;
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
To expand a little on Chris' answer:
When you ask for 8 char's of memory, thats all you get. You have no control over how the Runtime environment allocated that, and you don't need it. If you need two logical blocks of memory to be next to each other, then allocate one (bigger) block.
if you allocate a char[8], then referring to element 8 of that array (which you don't own, you own 0-7), is technically a protection fault. Whether or not it crashes your program is a matter of the alignment of the planets.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
I use VC++ 6.0 (SP5) (i use MFC), and wish to design a multithreaded application.
I have the following problem :
for (int i = 0; i < N; i++)
{
// Launch may be 4 or 5 threads
AfxBeginThread(thread1);
AfxBeginThread(thread2);
AfxBeginThread(thread3);
AfxBeginThread(thread4);
}
but i would like to execute ONLY ONE thread at time. (if i do not synchronize them, i will have 4*N threads at the same time !!!).
I am confused : what should i use : CSemaphore, CEvent, WaitForSingleObject(), WaitForMultipleObjects()....
Can you help me !
Thanks.
|
|
|
|
|
Have the ThreadFunc s of the threads synchronized with a CRITICAL_SECTION (the same for all of them). This post of mine shows a convenient way to do synchronization with these objects.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Bit confused. If you want only one thread running at a time, you could always not bother with threads and be single-threaded. That way you only get one thread running at once. Surely you're missing the point of multi-threading if you block them all to single thread execution?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
You can create each thread in suspended state and then resume them one by one waiting for each to finishing.
But like someone else siad, why create threads if you are just going to serialize execution.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I accept with TimSmith's reponse for Multithreading Synchronization. It's always better to create threads in suspended state and then start running in the next step.
Here the important thing is to create a thread pool. Like restrict your application for only these many threads.
I prefer you guys to refer "MultiThreadinding for Rookies" in MSDN.
Thanks
|
|
|
|
|
Thread pools are useless if you are serializing all activity. The whole point of threads are to:
1. Take advantage of multi-cpu systems.
2. Allow other operations to continue processing if one thread is stalled waiting for resources.
If all your threads are CPU bound, then you are actually hurting performance by using threads.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
1. Take advantage of multi-cpu systems.
I think this unfortunately cannot be taken advantage of in Windows NT/.../XP, as these OSs don't distribute a process among several CPUs (only different processes are scheduled to different CPUs). Linux, on the contrary, does per-process CPU distribution.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How to get a hotkey keyboard combination into a OnKeydown(NMHDR* pNMHDR, LRESULT* pResult).
|
|
|
|
|
why OnKeyDown?
see CDialog::PreTranslateMessage example
t!
|
|
|
|
|
I have project in MFC.And I insert data in database.How can I insert string that containts character ',for example "Customer's" ???
For insert string in database i must include this string in ' '
'Customer's ',but if i write this,i receive syntax error.
Help me please,how can I do this
|
|
|
|
|
I believe you put two of them, like this: customer''s. I've seen it done that way, when I did it, I was using filenames, so I replaced ' with ?, because a filename can't have a ?.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
CHris is correct, the standard SQL delimiter for ' is to double it up with ''.
However, a better way (if you're using the COM ADO interface) would be to write stored procedures and use ADODB.Command. With a proc you don't need to delimit anything, and you SQL will run much quicker with a smaller footprint, becuase procedures are compiled only once, not at query execution.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi All,
For those who are interested in P2P, Web Services, distributed network computing, there is an alternative pure Java based Distributed Network Computing platform. The software is downloadable at www.GreenTeaTech.com.
Chris
|
|
|
|
|
Hi All,
I'm not having a problem so much as getting a warning that I know why I'm getting, but dont want to get so I want to know if there is a better way of doing it? If that makes any sense!
What I have is a number that is 16bits in size, ie 0xFFFF is its biggest size! Trouble is I want it to be in a loop that breaks when its > FFFF which would be 0x10000, so I make it a 32bit (DWORD) number to accomplish this!
In my loop however I need to split up the lowest 16 bits into two 8 bit numbers. So if I have WORD Address = 0xFF9B; I want UCHAR Address1 = 0xFF and UCHAR Address2 = 0x9b;
I'm getting my 8 bit values with the following:
Address1 = (Address & 0xFF00)/0x100;
Address2 = (Address & 0xFF);
which works ok but each time i compile it obviously warns me I'm possibly loosing data from the DWORD address. I know the data I'm loosing is just the Most significant 16 bytes of the Address value which will always be 0x0000 so I dont care if I loose that.
My question is how do I stop the compiler warning me about this or is there a better way of doing what I need to do anyway?
|
|
|
|
|
Nevermind, I found using BYTE and LONG instead of UCHAR and DWORD it doesnt throw the warning!
|
|
|
|
|
Just use a cast:
Address1 = (UCHAR)(Address & 0xFF00)/0x100;
Address2 = (UCHAR)(Address & 0xFF);
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
Does anyone know how to supress the ability for the items in a listctrl to become highlighted?
|
|
|
|