使用Windows注册表 [英] Working with Windows Registry

查看:104
本文介绍了使用Windows注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在使用Windows注册表"Windows 7".我需要将.xml文件添加到

Windows注册表,我想通过窗口注册表访问.xml文件的数据

使用vc ++.

1)如何将.xml文件添加到窗口注册表.

2)如何使用vc ++通过窗口注册表访问.xml文件.

如果有人对如何使用窗口注册表有所了解.

请帮帮我.

提前致谢.

Hello,

I am working with Windows Registry "Windows 7". I need to add an .xml file to the

windows registry and i want to access the data of .xml file through window registry

using vc++.

1) How to add an .xml file to the window registry.

2) How to access the .xml file through window registry using vc++.

If anyone having idea of how to work with window registry.

Please Help me out.

Thanks in Advance.

推荐答案

请参见 ^ ],其中包含许多用于注册表处理的文章和示例.我还要重复我以前的评论,即您不应将文件存储在注册表中.
See here[^] for lots of articles and samples for Registry handling. I would also repeat my previous comment that you should not store files in the registry.


您好.
简单的答案是否"-您不能将xml文件添加到Windows注册表中……至少不能按照您的想法进行.
您可以做的是将XML文件 content 作为字符串值添加到注册表中.对于这样的任务,使用RegSetValueEx是可行的方法:
1)将xml文件的内容读入变量;
2)将XML内容用于RegSetValueEx的lpData参数-您可能需要执行强制转换.

但这很麻烦:注册表不是为大数据而设计的.如果您的xml文件内容不是Unicode(ANSI),则最大可用空间约为1MB(REG_SZ值的限制).此外,MSDN指出:
应将长值(大于2,048字节)存储在文件中,并将文件的位置存储在注册表中.这有助于注册表有效地执行."
Hello there.
Simple answer is no - you can''t add an xml file to the windows registry... at least not in the way you are thinking.
What you can do is add the xml file content to the registry, as a string value. For such a task, using RegSetValueEx is the way to go:
1) Read the content of your xml file into a variable;
2) Use the xml content for the lpData parameter of RegSetValueEx - you may need to perform casting.

But here''s the rub: the registry is not designed for large pieces of data. If your xml file content is not Unicode (ANSI), you will have a maximum of about 1MB available (the limit of the REG_SZ value). In addition, MSDN states:
"Long values (more than 2,048 bytes) should be stored in a file, and the location of the file should be stored in the registry. This helps the registry perform efficiently."


LONG WINAPI RegSetValueEx(
  _In_        HKEY hKey,
  _In_opt_    LPCTSTR lpValueName,
  _Reserved_  DWORD Reserved,
  _In_        DWORD dwType,
  _In_        const BYTE *lpData,
  _In_        DWORD cbData
);




对于d
详情请访问:

http://msdn.microsoft.com/zh-CN /library/windows/desktop/ms724875(v=vs.85).aspx [




for d
etails visit:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724875(v=vs.85).aspx[^]


这篇关于使用Windows注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆