?
Solved

COLORREF to registry

Posted on 1998-06-17
6
Medium Priority
?
616 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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