|
|
How can I read and write to the registry
through c/c++ or MFC?
Thanks,
Caleb
|
|
|
|
|
You can use the RegGet*** and RegSet**** functions.
Or better use the CRegisry-class. You can find it somewhere on codeproject.
|
|
|
|
|
Thanks Alot
|
|
|
|
|
MFC crys out for a registry class, but for some reason MS didn't include one.
I like the CRegistry class in Sam Blackburn's Windows Foundation Classes (not to be confused with other class libs that use the same name):
http://www.samblackburn.com/wfc/
Jim
|
|
|
|
|
I ran into the problem today with win2k disabling the tcpip protocol if the machine is not on any network - thereby killing the localhost option (and more) and making some of my transfer testing a pain. I recently saw a coding fix for this and thought 'this I must remember' and promptly forgot it...
Can't seem to find it again - can any of you gent's refresh my memory?
Thanks
/Boris
|
|
|
|
|
Before I added any icons, the correct icon IDR_ABCTYPE was associated with all of my .abc files. I added another icon, and even though IDR_ABCTYPE is still exactly the same, all my .abc files are now being shown with this new icon, which should have nothing to do with them. any ideas what I've messed up??
thanks,
Jake
|
|
|
|
|
I think there are several ways of fixing this, not sure that will do the trick for you but here they are;
1) Fire up your registry editor and go to;
HKEY_CLASSES_ROOT\.abc\
Check the '(default)' string entry, if its empty go to the sub-key 'DefaultIcon' and set the correct number. If it has a string in it, find the key it refers to ( from the '(default)' entry );
HKEY_CLASSES_ROOT\*the key*\
And do the same as above.
BTW: this is only a temporary fix, you should use one of the others to make sure it will work properly on other PC's.
2) Pass '/Unregister' as a command line option to your application (if your using MFC) then re-run it to correct the associations.
3) In VC++ open up your executable as a resource file, check that the new icon you added is at the end of the icon resource list. If it is not, then you will need to play around with the resouce.h file and make the icon's ID larger than that of the document's.
One of these should do the trick, but no promises.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I think it must have something to do with the IDs of the icons, because I played around with them and was able to produce different incorrect results After enough frustration I deleted the icons and made bitmaps to display on my buttons instead, so that's working now and the icons are back to normal Thanks for all of your help!
Jake
|
|
|
|
|
Something I've found over time is that Explorer keeps an icon cache which can get a bit corrupted. You might try "Rebuild Icons" in TweakUI to fix this (if that is what the problem is); also it might be called "Repair Icons" or something - can't quite remember just off hand.
> Andrew.
|
|
|
|
|
Have you problems with any other icons? I've had similar problems just using my system where icon associations kept changing to different icons...
Otherwise if its just the ABC files that your having trouble with, sorry cant help...
Richard.
|
|
|
|
|
It depends on what's stored in the DefaultIcon key. If it's "C:\path\to\your.exe,0" then the icon with the lowest ID (index 0) will be used. If you add icons that changes the relative order of the IDs, then what you're seeing can happen.
You can change that to "C:\path\to\your.exe,-102" to use the icon with ID 102 (note the minus sign).
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
Please excuse this crude example...
******* App Window *****
* *
* * Group Box ******** *
* * * *
* * **************** * *
* * * My Control * * *
* * **************** * *
* * * *
* ******************** *
* *
************************
My control and the group box both have the application window as their parent.
I cannot drag a file to my control as windows thinks the group box is the top window when the mouse moves over it. I have proved this using a global hook and calling WindowFromPoint() to determine the window under the mouse as you move the cursor around the screen. Also if I remove the group box, my control receives notification taht a file has been dropped onto it. My question is: Should my control be a child of the group box, or is there another way around the problem to make windows think my control is on top?
Thanks for any help you can provide.
Steve.
|
|
|
|
|
Check your tab order - your control should be after the group box in the tab order.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
I beg to differ. I had the same problem and I fixed it by placing my control before the group box in the tab order.
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
Thanks very much for replying I have got it working now. According to spy the window order before was:
App Window
Group Box
My Control
After a cal to SetWindowPos () to put my window on top the window order is now:
App Window
My Control
Group Box
|
|
|
|
|
I know this sounds like a stupid question...
I need to convert a double to a string to output it with SetWindowText().
I know how to get the string into the double (using atof() ), is there a better way to do it though?
Thanks... i'm just getting into C++ and windows programing from Perl and PHP and would appriciate any help.
|
|
|
|
|
strDouble.Format(_T("%2f"), dDouble);
This will work just fine, it will give you a precision of 2. Replace the 2 with however many numbers after the decimal you want it to be precise to.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Actually I believe you need to use %.2f to get a precision of 2...what you have will produce a string that containts a number with 2 overall digits
-Jesse
|
|
|
|
|
Actually I believe you need to use %.2f to get a precision of 2...what you have will produce a string that containts a number with 2 overall digits.
-Jesse
|
|
|
|
|
To get a double into a string:
double num = 10.0;
CString str;
str.Format("%d", num);
something.SetWindowText(str);
The syntax for Format probably looks really ugly if you've never programmed in C, but that %d grabs a double from after the comma and sticks it in there as a string. enjoy
Jake
|
|
|
|
|
Thanks... I do have some C experience, just not enough to know any of the prinf and formatting stuff.
|
|
|
|
|
How can you specify the accuracy (places after the decimal place) with str.Format()?
Thanks
Greg
|
|
|
|
|
you could eaven if you dont want to use the CString class
char buf[32];
double d = 123;
wsprintf(buf, "%d", d);
|
|
|
|
|
The examples so far have been wrong, %d is the format string for ints. Use %lf ("long float") for doubles.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|