Register entry using P / Invoke

I need to change registery value in windowsCE using C # and P / Invoke (RapiDll doesn't work there)

I know how to read the key:

private static string ReadRegKey(UIntPtr rootKey, string keyPath, string valueName,string value) { IntPtr hKey = IntPtr.Zero; if (RegOpenKeyEx(rootKey, keyPath, 0, KEY_READ, out hKey) == 0) { uint size = 1024; uint type = 0; string keyValue = null; StringBuilder keyBuffer = new StringBuilder(); keyBuffer.Append(value); if (RegQueryValueEx(hKey, valueName, IntPtr.Zero, ref type, keyBuffer, ref size) == 0) keyValue = keyBuffer.ToString(); RegCloseKey(hKey); return (keyValue); } return (null); // Return null if the value could not be read } 

Can anyone help me with this? (This is for changing btw device name)

+4
source share
3 answers
 RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WJST\WLAN", true); // set value of "CDInsert" to 1 reg.SetValue("CDInsert", 1, RegistryValueKind.DWord); // get value of "CDInsert"; return 0 if value not found int value = (int)reg.GetValue("CDInsert", 0); 
+4
source

Why don't you want to use the RegistryKey class from the Microsoft.Win32 namespace?

http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey%28v=VS.80%29.aspx

0
source

If you intend to write / read / query registry values ​​that are not inside the wow6432 node, and if you use a framework less than 4.0, you need the P / Invoke dll RegistryEX registry type

for example, you use a 32-bit application in a 64-bit application, due to virtualization, the registry will be under 32 bit node. If you need to create it under 64 bit, you need to use these p / invokes

We hope and wish you success.

0
source

All Articles