浅蓝色的琴弦
微风祈愿

2010年10月27日

     摘要: ARM寄存器介绍 ARM处理器共有37个寄存器。其中包括:31个通用寄存器,包括程序计数器(PC)在内。这些寄存器都是32位寄存器。以及6个32位状态寄存器。但目前只使用了其中12位。ARM处理器共有7种不同的处理器模式,在每一种处理器模式中有一组相应的寄存器组。任意时刻(也就是任意的处理器模式下),可见的寄存器包括15个通用寄存器(R0~R14)、一个或两个状态寄存器及程序计数器(P...  阅读全文
posted @ 2010-10-27 17:38 Platox 阅读(1081) | 评论 (0)编辑 收藏

2010年9月15日

今天使用WINCE IMAGE COM组件的时候
1>WinMain.obj : error LNK2001: unresolved external symbol CLSID_ImagingFactory
1>WinMain.obj : error LNK2001: unresolved external symbol IID_IImagingFactory

外部符号无法连接...

这会又的查MSDN了

原来是GUID导致的...

在 Microsoft Visual c + + 中,如果超过一个特定版本的编译器版本 GUID 必须初始化一次。由于这个原因有两个不同版本的 DEFINE_GUID 宏。一个版本只是声明对符号名的外部引用。其他版本实际上初始化符号名的 GUID 的值。如果您收到一个未初始化的符号名的该的 GUID GUID 错误 LNK2001。

注意DEFINE_GUID 宏 guiddef.h 头文件中的声明一个 GUID。此外定义 GUID,请在其中定义 $ GUID 的源文件中包括 INITGUID.H 头文件。

您可以确保您 GUID 获取初始化在两种方法之一:
  • 如果使用的预编译的头文件包括 INITGUID.H 头文件之前应该初始化它的实现文件中定义 GUID。(应用程序向导生成的 MFC 项目时使用预编译的头默认情况下)。
  • 如果您不使用预编译的头,定义 INITGUID 包括 OBJBASE.H 之前。(OBJBASE.H 包含由 OLE2.H)。
注意如果您正在使用预编译的头时,比某个特定版本的编译器版本,您可以在单个的头文件,包括其他头文件中包括 INITGUID.H 头文件。这将导致在其中此头文件是包含的所有源代码文件中定义 GUID。您将不会收到一个 LNK2001 错误,即使一个符号被定义多次。这是因为在 DEFINE_GUID 宏使用一个 DECLSPEC_SELECTANY 关键字。该关键字可确保链接器可以正确处理此多个定义。

http://support.microsoft.com/kb/130869 地址..



用#Define INITGUID
//头文件...
#undef INITGUID

就可以解决了.
posted @ 2010-09-15 15:51 Platox 阅读(490) | 评论 (0)编辑 收藏

2010年9月7日

以前做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了。。。。


posted @ 2010-09-07 21:12 Platox 阅读(504) | 评论 (0)编辑 收藏

2010年9月4日

类内用多线程函数时候提示需要使用静态成员。
由于我不希望用静态成员。于是翻了很多文章。 利用线程函数的参数要做文章。
线程函数原型

HANDLE CreateThread(
  LPSECURITY_ATTRIBUTES lpsa,
  DWORD lpsa,
  DWORD lpsa,
  DWORD cbStack,
  LPTHREAD_START_ROUTINE cbStack,
  LPTHREAD_START_ROUTINE lpStartAddr,
  LPVOID lpStartAddr,
  LPVOID lpvThreadParam,
  DWORD lpvThreadParam,
  DWORD fdwCreate,
  LPDWORD fdwCreate,
  LPDWORD lpIDThread
);

传入函数原型
DWORD ThreadProc(
  LPVOID lpParameter
);

方法如下

这样的话就可以使用非静态的类函数。。

posted @ 2010-09-04 17:31 Platox 阅读(166) | 评论 (0)编辑 收藏

2010年8月28日

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 函数的图像。

posted @ 2010-08-28 21:11 Platox 阅读(126) | 评论 (0)编辑 收藏
 

当进程在执行时,系统会关联此进程的消息队列
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 消息发送到主框架窗口,而将命令消息传送到其他对象。框架通过命令目标对象的标准序列传送命令,而在这些对象中,有一个应具有该命令的处理程序。每一个命令目标对象检查其消息映射,查看是否能处理传入的消息。

不同的命令目标类在不同的时间检查各自的消息映射。通常,类将命令传送到某些其他对象,给它们首先处理命令的机会。如果这些对象都不能处理此命令,则原始类检查自己的消息映射。然后,如果它自己也无法提供处理程序,则可能将此命令传送到更多的命令目标。(微软的定义)

posted @ 2010-08-28 14:39 Platox 阅读(124) | 评论 (0)编辑 收藏
 

在计算机科学中,“线程”和“进程”是两个相关的概念。二者都表示必须按特定顺序执行的指令序列。但是不同线程或进程中的指令可以并行执行。

进程存在于操作系统内,并对应于用户可看作为程序或应用程序的事物。另一方面,线程存在于进程内。因此,线程有时也称作“轻量进程”。每个进程都由一个或多个线程组成。

多个进程的存在使得计算机能够一次执行多个任务。而多个线程的存在使得进程能够分解工作以便并行执行。在多处理器计算机上,进程或线程可以在不同的处理器中运行。这使得真正的并行处理成为可能。

并不总是能够完全并行处理。有时候必须要同步线程。一个线程可能必须等待另一个线程的结果,或者一个线程可能需要独占访问另一个线程正在使用的资源。同步问题是多线程应用程序中出现 bug 的一个常见原因。有时候线程可能最终等待的是永远不会变得可用的资源。这导致了一种称为“死锁”的状况。



posted @ 2010-08-28 10:51 Platox 阅读(78) | 评论 (0)编辑 收藏

2010年8月25日

Wxwidget 很早就支持WINce了, 最近才拿起来用,
编译的路途是艰辛的。

系统WINDOWS xp,软件 vs2005,wince pocket pc SDK, wxwidget2.8.11。。
因为我有装standardsdk包。所以想编译STAND500 版本。 行不通。
所以老实的编译PPC版本.
我编译了 release 和 release dll 版。

编译release版比较简单。
编译release dll 需要注意。。
它有一个工具要生成一个头文件,不必要在意。等编译完,在编译一次。
2.8.11。有几个工程名字没改过来。相信大家都有注意。wx_的前缀。
还有一个nono.lib,其实就是wxwidget28.lib.  改了连接库的名字后先生成nono项目。
在生成gl项目。 他们依赖于一个头文件。。如果先生成gl项目。。生成nono项目就会报错。。

posted @ 2010-08-25 13:31 Platox 阅读(191) | 评论 (0)编辑 收藏

2010年8月23日

网上找了一些解决的办法,不是太详细。
VS2005 报WINCEROOT目录 ,修复PB6.0 和修复PB6.0SP1, 一定要修复PB6.0SP1,不然在VS2005菜单栏的工具-选项-就不会显示PB的设置

posted @ 2010-08-23 19:21 Platox 阅读(491) | 评论 (0)编辑 收藏

2010年8月21日

//建立注册字段
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.


posted @ 2010-08-21 12:00 Platox 阅读(558) | 评论 (0)编辑 收藏
仅列出标题  下一页