以前做SDK5.0的时候 就翻文
WINce 5.0或6.0 都要做这一步(反正我都做拉, 没做的没试过)
Build Options选项卡下,去掉Enable CE Target Control Support和Enable KITL;(如果不去掉可能会导致模拟器黑屏)
Environment选项卡,添加环境变量CE_MODULES_SERIAL=1,这是用来将DMA添加进来;(这十分重要)
下面是分支。。先是5.0的 我直接转别人的贴
2. 用记事本等工具打开\WINCE500\PBWorkspaces\MyPlatform\ExportSDK.sdkcfg
3.找到<PropertyBag NAME="DeviceEmulation">一段,添加如下信息:
<PropertyBag NAME="DeviceEmulation">
<Property NAME="Default Image">1</Property>
<PropertyBag NAME="1">
<Property NAME="ImageName">My Emulator</Property> ;(在VS上显示的模拟器的名字)
<Property NAME="VMID">{6CB9C6E3-E576-4580-BC1E-ADED62B97FFB}</Property>
<Property NAME="Default Skin"/>
<Property NAME="Height">400</Property>
<Property NAME="Width">240</Property>
<Property NAME="BitDepth">16</Property>
<Property NAME="Memory">128</Property>
<Property NAME="Bin Dest">Emulator\NK.bin</Property>
<Property NAME="Fixed Screen">1</Property>
<Property NAME="CpuName">ARMV4I</Property>
<Property NAME="DPIX">96</Property>
<Property NAME="DPIY">96</Property>
<Property NAME="SupportRotation">0</Property>
<Property NAME="Enabled">1</Property>
<Property NAME="Bin Path"></Property>
<Property NAME="Ethernet">1</Property>
<Property NAME="Ports">1</Property>
<Property NAME="AdditionalParameters">
</Property>
<PropertyBag NAME="Skins"/>
</PropertyBag>
</PropertyBag>
根据文档的说明修改相应的模拟器屏幕尺寸等信息。并添加如下内容:
<PropertyBag NAME="Added Files">
<PropertyBag NAME="{3B388597-0924-4102-ADFA-2519D2C3E11B}">
<Property NAME="Source">C:\WINCE500\PBWorkspaces\Emulator\Addfile</Property>
<Property NAME="Destination">Emulation</Property>
<Property NAME="Subfolders">0</Property>
</PropertyBag>
</PropertyBag>
C:\WINCE500\PBWorkspaces\Emulator\Addfile此路径是自己建立的,其中存放Emulator的nk.bin(此处仅放这一文件,否则生成SDK时会将这一目录下的内容全部压缩进去)
完成后保存文件。
4.Platform->SDK->Build SDK 等待完成。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/Veabol/archive/2009/09/04/4520154.aspx
下面是6.0的。。翻了很多文。始终找不到。后来去SDK对比一下。
打开SDK配置文件 如F:\WinCEspaces\WinCEOS\GPSos\GPSos\SDKs\SDK2\SDK2.sdkcfg
找到
<Property NAME="Enabled">1</Property>
<Property NAME="Bin Dest">Emulator\NK.bin</Property>
<Property NAME="Bin Path"></Property>
这个地方
貌似 感觉 Enadbled 是打开DMA选项的关键
<Property NAME="Bin Dest">Emulator\NK.bin</Property> 这个是一个目标文件夹。相对路径。貌似是相对SDK安装的路径
<Property NAME="Bin Path"></Property> 这个地方 我找了好久 原来是这个地方的错误。。这个路径是据对路径带文件名
如<Property NAME="Bin Path">c:\CrossbowBuild\15252\wpc\0409\DeviceEmulation\0409\PPC_USA.bin</Property>
改了这3个地方 基本就能生成带 DMA 选项的SDK了。。。。
Memory Device Contexts
内存设备环境
To enable applications to place output in memory rather than sending it to an actual device, use a special device context for bitmap operations called a memory device context.
要使程序能输出到内存中,而不是实际的设备上,使用操作位图的特殊设备环境,称之为内存设备环境。
A memory DC enables the system to treat a portion of memory as a virtual device。
内存设备环境能使系统处理的内存部分,就像虚拟设备一样。
It is an array of bits in memory that an application can use temporarily to store the color data for bitmaps created on a normal drawing surface.
它使得程序将正常的图的位图颜色数据临时存储在内存中
Because the bitmap is compatible with the device, a memory DC is also sometimes referred to as a compatible device context.
由于位图是与设备共存,内存设备环境有些时候被称之为共存设备环境。
The memory DC stores bitmap images for a particular device. An application can create a memory DC by calling the CreateCompatibleDC function.
内存设备环境存储的是一个特殊设备的位图图像, 应用程序可以调用
CreateCompatibleDC 函数创建内存设备环境。
The original bitmap in a memory DC is simply a placeholder。 Its dimensions are one pixel by one pixel. Before an application can begin drawing, it must select a bitmap with the appropriate width and height into the DC by calling the
SelectObject function.
最初在内存设备环境里的位图,仅仅预留位置。尺寸是一个像素一个像素的,在程序开始绘制之前,它必须调用的
SelectObject函数 到设备环境选择一张位图和适当的宽,高。
To create a bitmap of the appropriate dimensions, use the
CreateBitmap,
CreateBitmapIndirect, or
CreateCompatibleBitmap function. After the bitmap is selected into the memory DC, the system replaces the single-bit array with an array large enough to store color information for the specified rectangle of pixels.
若要创建的适当尺寸的位图,使用 CreateBitmap、 CreateBitmapIndirect 或 CreateCompatibleBitmap 的函数。 之后位图选入区内存后,系统会将单位数组替换数组大小不足以存储在指定的矩形的像素的颜色信息。
When an application passes the handle returned by CreateCompatibleDC to one of the drawing functions, the requested output does not appear on a device's drawing surface. Instead, the system stores the color information for the resultant line, curve, text, or region in the array of bits. The application can copy the image stored in memory back onto a drawing surface by calling the BitBlt function, identifying the memory DC as the source device context and a window or screen DC as the target device context.
当一个应用程序传递返回 CreateCompatibleDC 绘图功能之一的句柄时,请求的输出不显示设备的绘图图面上。 相反,系统的位数组中存储结果行、 曲线、 文本或区域的颜色信息。 应用程序可以将复制存储在内存回上绘图图面中通过调用标识作为源设备环境和窗口或屏幕设备环境作为目标设备环境的内存区的 BitBlt 函数的图像。
当进程在执行时,系统会关联此进程的消息队列
The system automatically creates a message queue for each thread
系统会自动为每个线程创建消息队列。
If the thread creates one or more windows, a message loop must be provided
如果该线程创建了一个或多个窗口,那么必须提供一个消息循环(控制台程序?可以不提供消息循环)
this message loop retrieves messages from the thread's message queue and dispatches them to the appropriate window procedures.
该消息循环检索线程消息队列里的消息,并派遣他们到相应的窗口过程
Because the system directs messages to individual windows in an application, a thread must create at least one window before starting its message loop.
由于在这个程序里系统把消息分发到不同窗口,那么这个线程必须在创建最后一个窗口之前运行消息循环
Most applications contain a single thread that creates windows.
更多的程序包含创建窗口的单个线程
A typical application registers the window class for its main window, creates and shows the main window, and then starts its message loop — all in the WinMain function.
一个典型的程序注册主窗口的窗口类,创建,显示主窗口,接着启动消息循环,它们都放在在WINMAIN函数里。
You create a message loop by using the GetMessage and DispatchMessage functions
你创建的消息循环需使用GetMessage 和 DispatchMessage 函数
If your application must obtain character input from the user, include the TranslateMessage function in the loop.
如果你的程序必须得到用户的字符输入,那么就要在循环里包含TranslateMessage函数。
TranslateMessage translates virtual-key messages into character messages.
TranslateMessage 转换在字符消息里的虚拟键消息
The following example shows a message loop for a thread that uses accelerators and displays a modeless dialog box. When TranslateAccelerator or IsDialogMessage returns TRUE (indicating that the message has been processed), TranslateMessage and DispatchMessage are not called. The reason for this is that TranslateAccelerator and IsDialogMessage perform all necessary translating and dispatching of messages.
接着下面的列子演示了使用加速器和显示非模态对话框的线程的消息循环,什么时候TranslateAccelerator 或 IsDialogMessage 返回真(指示那些消息是经过处理的), ), TranslateMessage 和 DispatchMessage是不能调用的。原因是TranslateAccelerator 和 IsDialogMessage执行所有必须转换或者派遣的消息。
大多数消息因用户与程序之间的交互而产生。命令通过鼠标单击菜单项或工具栏按钮或通过敲击快捷键生成。用户也通过其他方式生成 Windows 消息,例如移动窗口或调整窗口大小。当发生诸如程序启动或终止、窗口获取或失去焦点等事件时,将发送其他 Windows 消息。控件通知消息由鼠标单击或用户与某一控件(如对话框中的按钮或列表框 (ListBox) 控件)的其他交互生成。
CWinApp 类的 Run 成员函数检索消息并将其调度到适当的窗口。大多数命令消息被发送到应用程序的主框架窗口。由类库预定义的 WindowProc 获取消息并以不同的方式传送消息,传送方式取决于所接收的消息类别。
该过程接收部分
消息的初始接收器必须是窗口对象。Windows 消息通常直接由该窗口对象处理。通常产生于应用程序主框架窗口的命令消息被传送到命令传送中描述的命令目标链。
每一种能够接收消息或命令的对象都有各自的消息映射,该消息映射使消息或命令与其处理程序名配对。
当命令目标对象收到消息或命令后,它在其消息映射中搜索匹配项。如果找到该消息的处理程序,则调用此处理程序
通常将 Windows 消息发送到主框架窗口,而将命令消息传送到其他对象。框架通过命令目标对象的标准序列传送命令,而在这些对象中,有一个应具有该命令的处理程序。每一个命令目标对象检查其消息映射,查看是否能处理传入的消息。
不同的命令目标类在不同的时间检查各自的消息映射。通常,类将命令传送到某些其他对象,给它们首先处理命令的机会。如果这些对象都不能处理此命令,则原始类检查自己的消息映射。然后,如果它自己也无法提供处理程序,则可能将此命令传送到更多的命令目标。(微软的定义)
在计算机科学中,“线程”和“进程”是两个相关的概念。二者都表示必须按特定顺序执行的指令序列。但是不同线程或进程中的指令可以并行执行。
进程存在于操作系统内,并对应于用户可看作为程序或应用程序的事物。另一方面,线程存在于进程内。因此,线程有时也称作“轻量进程”。每个进程都由一个或多个线程组成。
多个进程的存在使得计算机能够一次执行多个任务。而多个线程的存在使得进程能够分解工作以便并行执行。在多处理器计算机上,进程或线程可以在不同的处理器中运行。这使得真正的并行处理成为可能。
并不总是能够完全并行处理。有时候必须要同步线程。一个线程可能必须等待另一个线程的结果,或者一个线程可能需要独占访问另一个线程正在使用的资源。同步问题是多线程应用程序中出现 bug 的一个常见原因。有时候线程可能最终等待的是永远不会变得可用的资源。这导致了一种称为“死锁”的状况。
、
//建立注册字段
This function creates the specified key. If the key already exists in the registry, the function opens it.
A remote application interface (RAPI) version of this function exists, and it is called CeRegCreateKeyEx (RAPI).
LONG RegCreateKeyEx(
HKEY hKey,
LPCWSTR lpSubKey,
DWORD Reserved,
LPWSTR lpClass,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
PHKEY phkResult,
LPDWORD lpdwDisposition
);
Parameters
- hKey
- [in] Handle to a currently open key or one of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
Windows CE does not support the HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA predefined reserved handle values.
The key opened or created by the RegCreateKeyEx function is a subkey of the key identified by the hKey parameter.
- lpSubKey
- [in] Pointer to a null-terminated string specifying the name of a subkey that this function opens or creates. The subkey specified must be a subkey of the key identified by the hKey parameter. This subkey must not begin with the backslash character (\). If the parameter is NULL, then RegCreateKeyEx behaves like RegOpenKey where it opens the key specified by hKey. In Windows CE, the maximum length of a key name is 255 characters, not including the terminating NULL character. You can also only nest 16 levels of sub-keys in Windows CE.
- Reserved
- [in] Reserved; set to 0.
- lpClass
- [in] Pointer to a null-terminated string that specifies the class (object type) of this key. This parameter is ignored if the key already exists. In Windows CE, the maximum length of a class string is 255 characters, not including the terminating NULL character.
- dwOptions
- [in] Registry key options. The following table shows the possible values for this parameter.
Value |
Description |
REG_OPTION_NON_VOLATILE |
Default setting. All registry keys are created as non-volatile and the information stored in memory is preserved when the OS is restarted. The RegSaveKey function saves keys that are non-volatile. |
REG_OPTION_VOLATILE |
All registry keys are created as volatile, and the information is stored in memory and is not preserved when the corresponding registry hive is unloaded. For HKEY_LOCAL_MACHINE, this occurs when the OS is shut down. The RegSaveKey function does not save volatile registry keys. This flag is ignored for keys that already exist. |
- samDesired
- [in] Ignored; set to 0 to ensure compatibility with future versions of Windows CE.
- lpSecurityAttributes
- [in] Set to NULL. Windows CE automatically assigns the key a default security descriptor.
- phkResult
- [out] Pointer to a variable that receives a handle to the opened or created key. When you no longer need the returned handle, call the RegCloseKey function to close it.
- lpdwDisposition
- [out] Pointer to a variable that receives disposition values. The following table shows possible values for this parameter.
Value |
Description |
REG_CREATED_NEW_KEY |
The key did not exist and was created. |
REG_OPENED_EXISTING_KEY |
The key existed and was simply opened without being changed. |
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.
Remarks
The key that the RegCreateKeyEx function creates has no values. An application can use the RegSetValueEx function to set key values.
An application can use RegCreateKeyEx to temporarily lock a portion of the registry. When the locking process creates a new key, it receives the disposition value REG_CREATED_NEW_KEY, indicating that it owns the lock. Another process attempting to create the same key receives the disposition value REG_OPENED_EXISTING_KEY, indicating that another process already owns the lock.
//开打注册表字段
This function opens the specified key.
A remote application interface (RAPI) version of this function exists, and it is called CeRegOpenKeyEx (RAPI).
LONG RegOpenKeyEx(
HKEY hKey,
LPCWSTR lpSubKey,
DWORD ulOptions,
REGSAM samDesired,
PHKEY phkResult
);
Parameters
- hKey
- [in] Handle to a currently open key or any of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
Windows CE does not support the HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA predefined reserved handle values.
- lpSubKey
- [in] Pointer to a null-terminated string containing the name of the subkey to open. If this parameter is NULL or a pointer to an empty string, the function will open a new handle to the key identified by the hKey parameter. In this case, the function will not close the handles previously opened.
- ulOptions
- [in] Reserved; set to 0.
- samDesired
- [in] Not supported; set to 0.
- phkResult
- [out] Pointer to a variable that receives a handle to the opened key. When you no longer need the returned handle, call the RegCloseKey function to close it.
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.
Remarks
Unlike the RegCreateKeyEx function, the RegOpenKeyEx function does not create the specified key if the key does not exist in the registry.
//写入字段值
This function stores data in the value field of an open registry key. It can also set additional value and type information for the specified key.
A remote application interface (RAPI) version of this function exists, and it is called CeRegSetValueEx (RAPI).
LONG RegSetValueEx(
HKEY hKey,
LPCWSTR lpValueName,
DWORD Reserved,
DWORD dwType,
const BYTE* lpData,
DWORD cbData
);
Parameters
- hKey
- [in] Handle to a currently open key or any of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
- lpValueName
- [in] Pointer to a string containing the name of the value to set. If a value with this name is not already present in the key, the function adds it to the key. If this parameter is NULL or an empty string, the function sets the type and data for the key's unnamed value. Registry keys do not have default values, but they can have one unnamed value, which can be of any type. The maximum length of a value name is 255, not including the terminating NULL character.
- Reserved
- [in] Reserved; must be zero.
- dwType
- [in] Type of information to be stored as the value's data. The following table shows the possible values for dwType.
Value |
Description |
REG_BINARY |
Specifies binary data in any form. |
REG_DWORD |
Specifies a 32-bit number. |
REG_DWORD_LITTLE_ENDIAN |
Specifies a 32-bit number in little-endian format. This is equivalent to REG_DWORD.
In little-endian format, a multi-byte value is stored in memory from the lowest byte (the little end) to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format.
|
REG_DWORD_BIG_ENDIAN |
Specifies a 32-bit number in big-endian format.
In big-endian format, a multi-byte value is stored in memory from the highest byte (the big end) to the lowest byte. For example, the value 0x12345678 is stored as (0x12 0x34 0x56 0x78) in big-endian format.
|
REG_EXPAND_SZ |
Specifies a null-terminated string that contains unexpanded references to environment variables (for example, %PATH%). |
REG_LINK |
Specifies a Unicode symbolic link. Used internally; applications should not use this type. |
REG_MULTI_SZ |
Specifies an array of null-terminated strings, terminated by two null characters. |
REG_NONE |
No defined value type. |
REG_RESOURCE_LIST |
Specifies a device-driver resource list. |
REG_SZ |
Specifies a null-terminated Unicode string. Do not use the REG_SZ type to store hard-coded paths to the system root. |
- lpData
- [in] Pointer to a buffer containing the data to be stored with the specified value name.
- cbData
- [in] Size, in bytes, of the information pointed to by the lpData parameter. If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of the terminating null character. The maximum size of data allowed in Windows CE is 4 KB.
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.
Remarks
Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the filenames stored in the registry. This helps the registry perform efficiently. Application elements such as icons, bitmaps, and executable files should be stored as files and not be placed in the registry.
Windows CE supports only the Unicode version of this function.
Windows Mobile Remarks
If RegSetValueEx is used to change a value, but the new value is the same as the previous value, no notification is returned.
//保存字段值
This function saves the specified key and all of its subkeys and values to a new file. If the specified key is not a predefined ROOT, it backs up to the ROOT of the hKey and saves there.
LONG RegSaveKey(
HKEY hKey,
LPCTSTR lpFile,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
Parameters
- hKey
- [in] Specifies a handle to the key where the save operation is to begin, or any of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
- lpFile
- [in] Pointer to a null-terminated string containing the name of the file in which the specified key and subkeys are saved.
- lpSecurityAttributes
- [in] Must be NULL.
Return Values
If the function succeeds, the return value is ERROR_SUCCESS.
The function may fail with GetLastError returning ERROR_NOT_SUPPORTED because it is not supported on the object store-based registry.
If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
Remarks
The RegSaveKey API is only supported by the hive-based registry. To save and restore data in the object store-based registry, see RegCopyFile and RegRestoreFile.
While you can call RegSaveKey with any registry key, in effect it only provides two choices. If it is called with HKEY_LOCAL_MACHINE, HKEY_CLASSES_ROOT, HKEY_USERS, or any key under those roots, it saves a copy of the entire system hive, which includes all keys under these roots. If it is called with HKEY_CURRENT_USER or any key under it, it saves a copy of the entire user hive, which includes all keys under HKEY_CURRENT_USER.
You can use the file created by RegSaveKey in subsequent calls to RegReplaceKey with HKEY_LOCAL_MACHINE to restore the system registry hive. To restore a saved user hive, move the file into the user's profile directory while the user is not logged in. Subsequent calls to SetCurrentUser will use the restored hive.
//读取键值
This function retrieves the type and data for a specified value name associated with an open registry key.
A remote application interface (RAPI) version of this function exists, and it is called CeRegQueryValueEx (RAPI).
LONG RegQueryValueEx(
HKEY hKey,
LPCWSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData
);
Parameters
- hKey
- [in] Handle to a currently open key or any of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
- lpValueName
- [in] Pointer to a string containing the name of the value to query. If this parameter is NULL or an empty string, the function retrieves the type and data for the key's unnamed value. A registry key does not automatically have an unnamed or default value. Unnamed values can be of any type.
- lpReserved
- [in] Reserved; set to NULL.
- lpType
- [out] Pointer to a variable that receives the type of data associated with the specified value. The following table shows the possible values that lpType can return.
Value |
Description |
REG_BINARY |
Specifies a binary data in any form. |
REG_DWORD |
Specifies a 32-bit number. |
REG_DWORD_LITTLE_ENDIAN |
Specifies a 32-bit number in little-endian format. This is equivalent to REG_DWORD.
In little-endian format, a multi-byte value is stored in memory from the lowest byte (the little end) to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format.
|
REG_DWORD_BIG_ENDIAN |
Specifies a 32-bit number in big-endian format.
In big-endian format, a multi-byte value is stored in memory from the highest byte (the big end) to the lowest byte. For example, the value 0x12345678 is stored as (0x12 0x34 0x56 0x78) in big-endian format.
|
REG_EXPAND_SZ |
Specifies a null-terminated string that contains unexpanded references to environment variables. For example, %PATH%. |
REG_LINK |
Specifies a Unicode symbolic link. Used internally; applications should not use this type. |
REG_MULTI_SZ |
Specifies an array of null-terminated strings, terminated by two null characters. |
REG_NONE |
No defined value type. |
REG_RESOURCE_LIST |
Specifies a device-driver resource list. |
REG_SZ |
Specifies a null-terminated Unicode string. |
The lpType parameter can be NULL if the type is not required.
- lpData
- [out] Pointer to a buffer that receives the value's data. This parameter can be NULL if the data is not required.
- lpcbData
- [in, out] Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the lpData parameter. When the function returns, this variable contains the size of the data copied to lpData.
If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, then lpcbData will also include the size of the terminating null character.
The lpcbData parameter can be NULL only if lpData is NULL.
If the buffer specified by lpData parameter is not large enough to hold the data, the function returns the value ERROR_MORE_DATA, and stores the required buffer size, in bytes, into the variable pointed to by lpcbData.
If lpData is NULL, and lpcbData is non-NULL, the function returns ERROR_SUCCESS, and stores the size of the data, in bytes, in the variable pointed to by lpcbData. This lets an application determine the best way to allocate a buffer for the value's data.
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.
Requirements
OS Versions: Windows CE 1.0 and later.
Header: Winreg.h.
Link Library: Coredll.lib.
//获取字段信息
This function retrieves information about a specified registry key.
A remote application interface (RAPI) version of this function exists, and it is called CeRegQueryInfoKey (RAPI).
LONG RegQueryInfoKey(
HKEY hKey,
LPWSTR lpClass,
LPDWORD lpcbClass,
LPDWORD lpReserved,
LPDWORDlpcSubKeys,
LPDWORD lpcbMaxSubKeyLen,
LPDWORD lpcbMaxClassLen,
LPDWORD lpcValues,
LPDWORD lpcbMaxValueNameLen,
LPDWORD lpcbMaxValueLen,
LPDWORD lpcbSecurityDescriptor,
PFILETIME lpftLastWriteTime
);
Parameters
- hKey
- [in] Handle to a currently open key or any of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
- lpClass
- [out] Pointer to a buffer that receives the key's class name. This parameter can be NULL.
- lpcbClass
- [in, out] Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpClass parameter. This size should include the terminating null character. When the function returns, this variable contains the length of the class string stored in the buffer. The count returned does not include the terminating null character. If the buffer is not big enough, the function returns ERROR_MORE_DATA, and the variable contains the size of the string, in characters, without counting the null character.
If lpClass is NULL, lpcbClass can be NULL.
If the lpClass parameter is a valid address, but this parameter is not, the function returns ERROR_INVALID_PARAMETER.
- lpReserved
- [in] Reserved; set to NULL.
- lpcSubKeys
- [out] Pointer to a variable that receives the number of subkeys contained by the specified key. This parameter can be NULL.
- lpcbMaxSubKeyLen
- [out] Pointer to a variable that receives the length, in characters, of the key's subkey with the longest name. The count returned does not include the terminating null character. This parameter can be NULL.
- lpcbMaxClassLen
- [out] Pointer to a variable that receives the length, in characters, of the longest string specifying a subkey class. The count returned does not include the terminating null character. This parameter can be NULL.
- lpcValues
- [out] Pointer to a variable that receives the number of values associated with the key. This parameter can be NULL.
- lpcbMaxValueNameLen
- [out] Pointer to a variable that receives the length, in characters, of the key's longest value name. The count returned does not include the terminating null character. This parameter can be NULL.
- lpcbMaxValueLen
- [out] Pointer to a variable that receives the length, in bytes, of the longest data component among the values of the key. This parameter can be NULL.
- lpcbSecurityDescriptor
- [in] Not used; set to NULL.
- lpftLastWriteTime
- [in] Ignored; set to NULL.
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.
//安全关闭注册表句柄
This function releases the handle of the specified key.
A remote application interface (RAPI) version of this function exists, and it is called CeRegCloseKey (RAPI).
LONG RegCloseKey(
HKEY hKey
);
Parameters
- hKey
- [in] Handle to the open key to close.
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.
Remarks
The handle for a specified key should not be used after it has been closed, because it will no longer be valid. Key handles should not be left open any longer than necessary.
The RegCloseKey function always writes information to the registry before returning, eliminating the need to flush keys in the Windows CE registry.
删除键值
This function recursively deletes all subkeys of a named subkey of a specified registry key.
A remote application interface (RAPI) version of this function exists, and it is called CeRegDeleteKey (RAPI).
LONG RegDeleteKey(
HKEY hKey,
LPCWSTR lpSubKey
);
Parameters
- hKey
- [in] Handle to a currently open key or one of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
The key specified by the lpSubKey parameter must be a subkey of the key identified by hKey.
- lpSubKey
- [in] Pointer to a null-terminated string specifying the name of the key to delete. This parameter cannot be NULL.
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.
Remarks
If the function succeeds, RegDeleteKey removes the specified key from the registry. The entire key, including all of its values, is removed. An application cannot call RegDeleteKey for a key that an application currently has open.
To open the key, use the RegCreateKeyEx or RegOpenKeyEx function.