C#读取注册表项,将其与ini配置文件进行比较,如果与配置部分下的返回结果匹配,则执行其他操作

发布于 2024-09-27 17:39:06 字数 555 浏览 1 评论 0原文

我遇到了以下问题,并且我的 C# 入门水平请帮助解决如何完成此任务?

设想: 1.我的注册表项:

__DatabaseConnection
|____config1
     value: username1
     value: password1
|____config2
     value: username2
     value:password2
  1. 我的ini文件:

    [配置z]

    数据库=MSSQL 数据库名称= ABC 主机=本地主机\项目

    [配置1]

    数据库=ORACLE 数据库名称= DEF 主机=服务器/数据

    [配置N] 名称=xxxx Age=XXXX

问题:

我想读取这些注册表项,将它们与 ini 文件中的配置部分进行比较。

如果匹配,则返回数据库/名称/主机的值。 连接数据库服务器,删除数据库。 重复此过程,直到搜索到注册表中的所有项并删除所有数据库。

请帮忙! 此致, 杜伊。

I got below problem and with my entry level of C# please help on how to get this be done?

Scenario:
1. My registry keys:

__DatabaseConnection
|____config1
     value: username1
     value: password1
|____config2
     value: username2
     value:password2
  1. My ini file:

    [configz]

    Database=MSSQL
    DatabaseName= ABC
    Host=localhost\projects

    [config1]

    Database=ORACLE
    DatabaseName= DEF
    Host=server/data

    [configN]
    Name=xxxx
    Age=XXXX

Question:

I want to read those registry keys compare them to those configuration sections in ini file.

If match, return those value of database/ name/ host.
Connect to database server, delete the database.
Repeate the process until all keys in the registry is searched and all databases deleted.

Please help!
Best Regards,
Duy.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

将军与妓 2024-10-04 17:39:06

有关 C# 中的注册表内容,请查看此处,特别是 GetValue() 方法。

http://msdn.microsoft.com/en-us/ library/microsoft.win32.registry.aspx

public static Object GetValue(
    string keyName,
    string valueName,
    Object defaultValue
)

要阅读 IniFiles,请参阅此帖子:读/写INI文件

For registry stuff in C# look here, particuarly the GetValue() method.

http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx

public static Object GetValue(
    string keyName,
    string valueName,
    Object defaultValue
)

For reading IniFiles see this SO post: Reading/writing an INI file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文