Well, what it does actually depends on *how* the OEM implemented the
persistent registry. There are two basic ways: hive-based and OEM-based.
For the OEM-based case, which is the way everything worked back in the CE
3.0 days, your call to RegFlushKey() calls a function set up by the OEM
during the boot process. When that function returns the whole registry has
been written to wherever the OEM keeps it. The function would be set up in
OEMInit(), if you can look at the OEM's implementation of that and see if
they are setting pWriteRegistryToOEM somewhere (it's a function pointer).
Note that, in this case, the OEM also has to set pReadRegistryFromOEM in
order to get the registry read at startup.
In the hive-based case, the OS itself decides whether anything in the
registry has changed or not when you call RegFlushKey() and sends the
changes to the hive, which is stored somewhere in the filesystem. There are
numerous settings that you have to make to cause hive-based registry to
work.
You should probably read the Platform Builder documentation on the subject,
search in microsoft.public.windowsce.platbuilder, etc. This question has
nothing to do with .NET CF, obviously.
Paul T.
[quoted text, click to view] "bbomer" <bbomer@belcan.com> wrote in message
news:1121975039.156599.234620@g47g2000cwa.googlegroups.com...
>I have a CE device that supports persistent registry. The device
> documentation says "To save the registry you must call the Standard
> Windows CE API function RegFlushKey(HKEY_LOCAL_MACHINE);"
>
> This is what I have as far as some generic code right now:
>
> [DllImport("coredll.dll", EntryPoint="RegFlushKey", SetLastError=true)]
>
> private static extern uint RegFlushKey(uint hKey);
>
> private void button1_Click(object sender, System.EventArgs e)
> {
> try
> {
> long test = RegFlushKey(0x80000002);
> System.Diagnostics.Debug.WriteLine(test);
> }
> catch (Exception ex)
> {
> System.Diagnostics.Debug.WriteLine(ex,"ERROR");
> }
> }
>
> What does "RegFlushKey" actually do? I have run this code and it
> returns "0" which I assume means that it completed without error.
> However it doesn't seem to do anything as the registry is restored to
> the original upon reboot.
>
> The device documentation mentions a "CEREG.BIN" file, but I can't find
> that anywhere. I have built the CE image using platform builder, do I
> need to do something there to enable persistent registry?
>
> Note: device is a Kontron MOPSlcd7 Pentium III based PC/104
>