Solved

COLORREF to registry

Posted on 1998-06-17
6
611 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iSeries DB2 Query 2 95
twoTwo  challenge 35 101
noX challenge 17 112
Thin secure Windows 10 5 93
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

16 Experts available now in Live!

Get 1:1 Help Now