Pelles C forum

C language => Pocket PC and Smartphone questions => Topic started by: tesla on April 23, 2008, 09:38:13 PM

Title: write registry
Post by: tesla on April 23, 2008, 09:38:13 PM
Is there a relatively simple and safe way to write a value to the registry?  Do I need to check for the registry key first and create it if it doesn't exist?

Thanks!
Title: Re: write registry
Post by: Stefan Pendl on April 23, 2008, 10:04:55 PM
See Registry (Windows) (http://msdn2.microsoft.com/en-us/library/ms724871%28VS.85%29.aspx) at the MSDN.
Title: Re: write registry
Post by: tesla on June 27, 2008, 09:00:04 PM
Making some progress :)

I am writing data into registry at expected location.  But the data is not showing as expected, I just see blocks when using PHM Registry Viewer.  Also the compiler seems to require a lot of parameters to be Unicode (I think?).

For example param #2 in the reg create complained until I put the L modifier on it...

Code: [Select]
  HKEY hk;
  char Value[1024];

  RegCreateKeyEx(HKEY_CURRENT_USER,L"Software\\test",0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hk,NULL);

  //_snwprintf(wchBuf, NELEMS(wchBuf), L"%f", x);
  sprintf(Value,"%f",x);
  RegSetValueEx( hk, L"x", 0, REG_SZ, Value, strlen(Value)+1 );

  RegCloseKey(hk);
Title: Re: write registry
Post by: iancasey on August 26, 2008, 12:05:02 AM
I know this is an older thread, but I thought I'd add my 2 cents.

I like to keep all my programs and data on an SD disk, this is because I keep forgetting to recharge the ppc.
If you have had a PPC for very long then most likely you have needed to hit the reset button or left it to the point the backup battery died.
I'm not sure if this this resets the registry but why take the chance ( I don't).
If you use external memory (SD card) then why not write to an ini file in the default program folder?

Ian