|
I have a list of key/value pairs stored in the registry, Each key/pair is a filename for a file that is available to my application. If a user deletes a file, I want to also delete the key from the registry. So I am creating a function to iterate through the registry deleting the value if it does not exist. RegQueryInfoKey() and RegEnumValue() seem to be the functions I need. But the spec for RegEnumValue() is a bit confusing.
While using RegEnumValue, an application should not call any registry functions that might change the key being queried.
Does this mean I cannot delete the key within the loop (how does deleting effect the remaining values?), or is it safe to delete? If the former, I would have to build an array of all keys flagged for delete which I would prefer to avoid.
|
|
|
|
|
>>Does this mean I cannot delete the key within the loop
Yes!
|
|
|
|
|
It's similar to iterating through an STL collection - if you change the collection, any iterators may become invalid. What could happen in the registry, if you delete values while enumerating, is the enumeration will skip some values.
|
|
|
|
|
When enumerating, the docs say to pass 0 on the first call and to increase it each time after, just a standard loop. What I'm asking is, if I start this loop, increasing the index each time, then when I find a certain key I want to delete, is it safe to delete (NOT increasing the index will cause it to point to the next value). This is the same method I would deal with any dynamically resizing array such as a vector. My main concern is, if I delete the key, will the other keys rearrange themselves?
I don't really want to use two loops because the registry is already slow, there may be up to a hundred keys to iterate through.
|
|
|
|
|
If the behavior isn't documented in MSDN, I wouldn't rely on it.
|
|
|
|
|
Thats what I thought, still better to ask and be sure though. Thankyou.
|
|
|
|
|
Why do you even need to call RegEnumValue() ? Since you know where the key/value pairs are stored, can you not just call RegDeleteValue() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Why do you even need to call RegEnumValue()? Since you know where the key/value pairs are stored, can you not just call RegDeleteValue()?
Because at runtime I don't know the keyname for any of the values. Basically, I have built a script engine into my project. This engine compiles scripts and stores them. In an attempt to make it more difficult for the user to cheat, I create a CRC-32 hash of the script file and then use this as both a reg key and filename. I need to enumerate the registry because A user may have deleted a compiled file thus leaving the key un-resolvable.
This function I am creating runs only once during execution and eliminates any discrepancies in the registry.
|
|
|
|
|
Any tips on optimizing serialization performance when you have a lot (300,000) of small objects contained in nested ob arrays? Seems to be pretty slow, despite the small overall data size (6MB file). Looks like the performance issue is caused by the sheer # of objects.
|
|
|
|
|
Is there a message I can send to a Dialog Box that allows me to change its Border from "resizing" to "Dialog Frame"?
|
|
|
|
|
Borders are defined with styles WS_??? and/or extended styles ES_???
led mike
|
|
|
|
|
Thanks you are correct, it is WS_THICK for a resizable border and WS_BORDER for a regular one. My question is this, I have already created a dialog box that has a resizable border, is it possible to send a message to the dialog box and change it from WS_THICK to WS_BORDER without destroying and recreating the dialog box?
|
|
|
|
|
Is it the window style you want to change or merely prevent resizing? If it's your own dialog (you coded it) you can define a WM_USER message, check for the message in your main loop at set up the MINMAXINFO accordingly. Changing the window style is a little more complicated, you would have to use the SetWindowLong() function (again after receiving a custom message). If the dialog is another process, you will have to register the window message with the OS first.
|
|
|
|
|
You could handle the WM_NCHITTEST message. First call the default handler and if the cursor is over a resizable border simply return HTBORDER to disable resizing with the mouse. To totally disable resizing you would also have to disable the Size command in the system menu.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
LONG_PTR style = GetWindowLongPtr(hwndDlg, GWL_STYLE);
SetWindowLongPtr(hwndDlg, GWL_STYLE, (style & ~WS_THICKFRAME)|WS_BORDER);
|
|
|
|
|
TheDelChop wrote: is it possible to send a message to the dialog box and change it from WS_THICK to WS_BORDER without destroying and recreating the dialog box?
Yes but it is not a "Message". The style bits are contained in the "window long" member. If you have a MFC CDialog then use CDialog::ModifiyStyle(...) otherwise use GetWindowLong(...), SetWindowLong(...) API's.
led mike
|
|
|
|
|
What code or class can I use to get the IP address of the computer my software will be running on? I am using Visual C++ (MFC) 2003. (No .NET)
|
|
|
|
|
What's wrong with gethostname() followed by gethostbyname() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Nothing is wrong with them, I just didn't know about those functions.
Thanks, I'll be sure to look them up.
Peace,
BP
|
|
|
|
|
does anyone possibly know how i would get my c++ application (w MFC in vc6.0) to emulate a normal left click? (press, release)
(that works globably, so it can be inactive/minimized and click in my applications for me)
thanks!
/Johannes
|
|
|
|
|
It usually requires sending the appropriate message to the control you want to interact with.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
So you mean that mouse clicking can not be globaly emulated? But keyboard buttons can be..
there must be some way?
thanks.
/Johannes
|
|
|
|
|
Johpoke wrote: So you mean that mouse clicking can not be globaly emulated? But keyboard buttons can be..
Where in the world did you infer this from. Controls respond to both keyboard or mouse, and either can be emulated. One such way is via SendInput() . There are likely other solutions, but without more details as to what you are wanting to achieve...
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i searched for that and sneaked around to microsoft, were i found mouse_event, then i found this:
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,NULL);
and
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,NULL);
which does exactly what i need!
thanks!!
/Johannes
|
|
|
|
|
SendInput() has superseded mouse_event() on Windows NT/2000/XP systems.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|