Solved

COLORREF to registry

Posted on 1998-06-17
6
608 Views
Last Modified: 2013-11-20
I need to write a COLORREF to the registry.
I am thinking of using 3 integers each representing R, G & B.   How do i extract these value from a COLORREF then?

Is the any other better way to do the storing?
0
Comment
Question by:nancytan
6 Comments
 
LVL 1

Accepted Solution

by:
Andy_Keys earned 20 total points
ID: 1318150
Why Not just write it as binary data COLORREF is just a unsigned long ie 32bits.  Try something like
RegCreateKeyEx( HKEY_CURRENT_USER,
            RegKey,      0,NULL,                                          REG_OPTION_NON_VOLATILE,                              KEY_WRITE,NULL,      &RestoreKey,&Disp) )
RegSetValueEx( RestoreKey, <aKey>,0, REG_BINARY, &ColourRef,sizeof(COLORREF) );

0
 

Author Comment

by:nancytan
ID: 1318151
I have a problem with 5th parameter of the function RegSetValueEx

COLORREF crText;      
crText = RGB(0,0,255);
RegSetValueEx( RestoreKey, szKeyColref,0, REG_BINARY, &crText, sizeof(COLORREF) );

: error C2664: 'RegSetValueExA' : cannot convert parameter 5 from 'unsigned long *' to 'const unsigned char *'

How should i code it?
0
 
LVL 1

Expert Comment

by:Andy_Keys
ID: 1318152
Try (unsigned char*)&crText (Compiled when I tried at least)
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 10

Expert Comment

by:RONSLOW
ID: 1318153
If you're using MFC and storing application info, use WriteProfileInt .. a COLORREF is just an int. (you may need to cast to int when writing .. on read GetProfileInt returns an unsigned int.


0
 

Expert Comment

by:ysgr
ID: 1318154
you can convert the value of  COLORREF to string and u can also store it as a string
ysgr
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1318155
but it is ALREADY an int .. no conversion needed.  Converting to/from a string would (probably) involve sscanf and .Format etc .. more mess than you need
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now