Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

COLORREF to registry

Posted on 1998-06-17
6
Medium Priority
?
618 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
Technology Partners: 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!

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

609 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