|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionRegistry is the system database for storing paires of Key and Value in the Windows operating systems. Windows CE system registry is organized as hierarchical (tree) structure. It is used to store configuration information for operating system, applications and hardware devices. Also, the registry contains information about installed applications, drivers and available hardware. Pocket PC registry is very similar to desktop Windows registry. You can use regedit utility to look at your desktop PC Structure. BackgroundPocket PC registry has four main root nodes & several additional:
The functions for working with Pocket PC Registry, e.g. opening ROOT, creating keys and values, deleting nodes, enumerating childs are contained in coredll.dll system library. This set of functions are part of WinAPI. Using the codeThe library contains a single class
The example of their usage: PocketRegistry.CERegister.RegSetStringValue(PitReg.RegRoot.HKEY_CURRENT_USER, "pocketpc\\CERegistry", "StringValue", "123");
Here also, some brief examples of DllImport Attribute usage: Creating Registry Key://
// RegCreateKeyEx
//
[System.Runtime.InteropServices.DllImport("coredll.dll")]
private static extern int RegCreateKeyEx(
uint hKey,
string lpSubKey,
uint Reserved,
string lpClass,
uint dwOptions,
uint samDesired,
uint lpSecurityAttributes,
ref uint phkResult,
ref uint lpdwDisposition
);
Open Registry Key://
// RegOpenKeyEx
//
System.Runtime.InteropServices.DllImport("coredll.dll")]
private static extern int RegOpenKeyEx(
uint hKey,
string lpSubKey,
uint ulOptions,
uint samDesired,
ref uint phkResult
);
Querying Registry Value://
// RegQueryValueEx
//
[System.Runtime.InteropServices.DllImport("coredll.dll")]
private unsafe static extern int RegQueryValueEx(
uint hKey,
string lpValueName,
uint lpReserved,
out uint lpType,
byte * lpData,
ref uint lpcbData
);
There is a trick for getting string values. You should first retrieve the length of the value and then retrieve the value in the buffer: private static string GetStringValue(uint Key, string Name)
{
uint buflen = 0;
uint type = 0;
char []str = null;
unsafe
{
//Get the length of the value:
int r = RegQueryValueEx(Key,Name,0,out type,null,ref buflen);
if (type!=(uint)RegType.REG_SZ) throw new Exception ("The key is not of string value");
//Create a buffer for the value:
byte[] rez_buf = new byte
Further InformationFor further info you may refer MSDN History
|
|||||||||||||||||||||||||||||||||||||||||||||||