Click here to Skip to main content
16,007,809 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generaldf attack Pin
colspan=220-Aug-02 0:02
susscolspan=220-Aug-02 0:02 
QuestionWhat I have to do? I want to create MP3 players. Pin
sonshiro19-Aug-02 23:55
sonshiro19-Aug-02 23:55 
AnswerRe: What I have to do? I want to create MP3 players. Pin
Christian Graus20-Aug-02 0:51
protectorChristian Graus20-Aug-02 0:51 
AnswerRe: What I have to do? I want to create MP3 players. Pin
Stephane Rodriguez.20-Aug-02 1:47
Stephane Rodriguez.20-Aug-02 1:47 
AnswerRe: What I have to do? I want to create MP3 players. Pin
brianwelsch20-Aug-02 4:14
brianwelsch20-Aug-02 4:14 
GeneralRegistry Pin
udayGovekar19-Aug-02 23:18
udayGovekar19-Aug-02 23:18 
GeneralRe: Registry Pin
Tomasz Sowinski20-Aug-02 0:03
Tomasz Sowinski20-Aug-02 0:03 
GeneralRe: Registry Pin
Steven Gregg20-Aug-02 6:44
Steven Gregg20-Aug-02 6:44 
Following code isn't perfect but it works and should get you started. If you look at the documentation for RegSetValueEx() you can set the dwType param to REG_DWORD for numbers but I usually just deal with strings and use atoi() or similar to convert.


bool bGetRegistryEntry(const HKEY hKey, const char* name, unsigned char* const dest)
{
bool bReturnVal = true;
unsigned long lType = 0;
unsigned long ulSize = MAX_PATH;


if (ERROR_SUCCESS != RegQueryValueEx(hKey, name, NULL, &lType, dest, &ulSize))
{
bReturnVal = false;
}

return (bReturnVal);
}

bool bSetRegistryEntry(const HKEY hKey, const char* name, unsigned char const* dest)
{
bool bReturnVal = true;
unsigned long lType = 0;
LONG lRESULT = 0;

lRESULT = RegSetValueEx(hKey, name, 0, REG_SZ, dest, _mbslen(dest) + 1);
//ERROR_ACCESS_DENIED indicates it already exists
if ((lRESULT != ERROR_SUCCESS) && (lRESULT != ERROR_ACCESS_DENIED))
{
bReturnVal = false;
}
return (bReturnVal);
}


// Open or create registry.
void vRegOpenKey()
{
HKEY hKey=0;
//char *my_App = "Registry_Example";
CString sAppId = "SOFTWARE\\RegKeyExample";
bool bReturnVal = false;
DWORD dwDisposition = 0;

if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, sAppId, 0, KEY_READ, &hKey))
{

LONG lRESULT = 0;
lRESULT = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
sAppId,
0,
REG_NONE,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisposition);
if (lRESULT != ERROR_SUCCESS)
{
MessageBox(NULL, "Registry not available!", NULL, NULL);
return;

}
}

const unsigned char name[5] = "this";
if (!bSetRegistryEntry(hKey, "value1", &name[0]))
{
MessageBox(NULL, "Unable to set registry value1", NULL, NULL);
}
else
{
unsigned char name2[5];
if (bGetRegistryEntry(hKey, "value1", name2))
{
CString sText;
sText.Format("Registry value1 is %s", name2);
MessageBox(NULL, sText, NULL, NULL);
}
else
{
MessageBox(NULL, "Unable to get registry value1", NULL, NULL);
}
}


RegCloseKey( hKey );

}
GeneralCoding plugins with dlls Pin
makom4219-Aug-02 22:42
makom4219-Aug-02 22:42 
GeneralRe: Coding plugins with dlls Pin
Tomasz Sowinski20-Aug-02 0:18
Tomasz Sowinski20-Aug-02 0:18 
GeneralRe: Coding plugins with dlls Pin
makom4220-Aug-02 0:54
makom4220-Aug-02 0:54 
GeneralRe: Coding plugins with dlls Pin
Tomasz Sowinski20-Aug-02 0:56
Tomasz Sowinski20-Aug-02 0:56 
GeneralRe: Coding plugins with dlls Pin
Roger Allen20-Aug-02 2:38
Roger Allen20-Aug-02 2:38 
GeneralDifferent views Pin
tulc_kris19-Aug-02 22:31
tulc_kris19-Aug-02 22:31 
GeneralRe: Different views Pin
Tomasz Sowinski20-Aug-02 0:58
Tomasz Sowinski20-Aug-02 0:58 
GeneralControl Painting Pin
albean19-Aug-02 20:15
albean19-Aug-02 20:15 
GeneralRe: Control Painting Pin
Paul M Watt19-Aug-02 21:18
mentorPaul M Watt19-Aug-02 21:18 
GeneralRe: Control Painting Pin
albean19-Aug-02 21:56
albean19-Aug-02 21:56 
QuestionHow the program can know that the screen is updated Pin
Chintan19-Aug-02 20:04
Chintan19-Aug-02 20:04 
AnswerRe: How the program can know that the screen is updated Pin
Christian Graus19-Aug-02 20:50
protectorChristian Graus19-Aug-02 20:50 
GeneralSite feedback Pin
Anonymous_Posting19-Aug-02 19:46
sussAnonymous_Posting19-Aug-02 19:46 
GeneralRe: Site feedback Pin
Chris Maunder20-Aug-02 1:06
cofounderChris Maunder20-Aug-02 1:06 
GeneralProblem in getting a field value of a dialog Pin
Didaa19-Aug-02 19:38
Didaa19-Aug-02 19:38 
GeneralRe: Problem in getting a field value of a dialog Pin
Paul M Watt19-Aug-02 20:01
mentorPaul M Watt19-Aug-02 20:01 
GeneralRe: Problem in getting a field value of a dialog Pin
jhwurmbach19-Aug-02 21:36
jhwurmbach19-Aug-02 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.