windows 注册表_Windows注册表简介

windows 注册表

The Registry is simply a database that an application can use to store and retrieve configuration information (last window size and position, user options and information or any other configuration data). Registry also contains information about Windows (95/98/NT) and about your Windows configuration.

注册表只是一个数据库,应用程序可以使用该数据库来存储和检索配置信息(最后一个窗口的大小和位置,用户选项和信息或任何其他配置数据)。 注册表还包含有关Windows(95/98 / NT)和Windows配置的信息。

The Registry "database" is stored as a binary file. To find it, run regedit.exe (Windows registry editor utility) in your Windows directory. You will see that information in Registry is organized in a similar way to Windows Explorer. We can use regedit.exe to view registry information, change it or to add some information to it. It is obvious that modifications of the registry database could lead to a ​system crash (of course if you don't know what you are doing).

注册表“数据库”存储为二进制文件。 要找到它,请在Windows目录中运行regedit.exe(Windows注册表编辑器实用程序)。 您将看到Registry中的信息的组织方式与Windows Explorer相似。 我们可以使用regedit.exe查看注册表信息,对其进行更改或向其中添加一些信息。 显然,修改注册表数据库可能会导致系统崩溃(当然,如果您不知道自己在做什么)。

INI vs.注册表 ( INI vs. Registry )

It is probably very well known that in the days of Windows 3.xx INI files were a popular way of storing application information and other user-configurable settings. The most terrifying aspect of INI files is that they are just text files that the user can easily edit (change or even delete them). In 32-bit Windows Microsoft recommends using Registry to store the type of information that you would normally place in INI files (users are less likely to alter registry entries).

众所周知,在Windows 3.xx时代,INI文件是存储应用程序信息和其他用户可配置设置的流行方法。 INI文件最可怕的方面是它们只是文本文件,用户可以轻松地对其进行编辑(更改甚至删除)。 在32位Windows中,Microsoft建议使用注册表来存储通常放置在INI文件中的信息类型(用户更改注册表项的可能性较小)。

Delphi provides full support for changing entries in the Windows System Registry: via the TRegIniFile class (same basic interface as the TIniFile class for users of INI files with Delphi 1.0) and TRegistry class (low-level wrapper for the Windows registry and functions that operate on the registry).

Delphi为更改Windows系统注册表中的条目提供了全面的支持:通过TRegIniFile类(与使用Delphi 1.0的INI文件的用户使用的TIniFile类相同的基本接口)和TRegistry类(Windows注册表和运行功能的低级包装)在注册表上)。

简单提示:写入注册表 ( Simple Tip: Writing to the Registry )

As mentioned before in this article, basic registry operations (using code manipulation) are reading information from ​Registry and writing information to the database.

如本文前面所述,基本注册表操作(使用代码操作)正在从注册表中读取信息并将信息写入数据库。

Next piece of code will change the Windows wallpaper and disable the screen saver using TRegistry class. Before we can use TRegistry we have to add Registry unit to the uses clause at the top of source-code.

下一段代码将更改Windows墙纸,并使用TRegistry类禁用屏幕保护程序。 在使用TRegistry之前,我们必须在源代码顶部的uses子句中添加Registry单元。

~~~~~~~~~~~~~~~~~~~~~~~~~uses registry;procedure TForm1.FormCreate(Sender: TObject) ;varreg:TRegistry;beginreg:=TRegistry.Create;with reg do begintryif OpenKey('\Control Panel\desktop', False) then begin//change wallpaper and tile itreg.WriteString ('Wallpaper','c:\windows\CIRCLES.bmp') ;reg.WriteString ('TileWallpaper','1') ;//disable screen saver//('0'=disable, '1'=enable)reg.WriteString('ScreenSaveActive','0') ;//update changes immediatelySystemParametersInfo (SPI_SETDESKWALLPAPER,0, nil,SPIF_SENDWININICHANGE) ;SystemParametersInfo (SPI_SETSCREENSAVEACTIVE,0, nil,SPIF_SENDWININICHANGE) ;endfinallyreg.Free;end;end;end;~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~使用注册表;过程TForm1.FormCreate(Sender:TObject); varreg:TRegistry; beginreg:= TRegistry.Create; with reg执行begintryif OpenKey('\ Control Panel \ desktop',False)然后开始//更改墙纸并将其平铺reg.WriteString('Wallpaper','c:\ windows \ CIRCLES.bmp'); reg.WriteString('TileWallpaper' ,'1'); //禁用屏幕保护程序//('0'=禁用,'1'=启用)reg.WriteString('ScreenSaveActive','0'); //立即更新更改SystemParametersInfo(SPI_SETDESKWALLPAPER,0,nil ,SPIF_SENDWININICHANGE);系统参数信息(SPI_SETSCREENSAVEACTIVE,0,nil,SPIF_SENDWININICHANGE);最终注册为free; end; end; end; ~~~~~~~~~~~~~~~~~~~~~~~~

Those two lines of code that start with SystemParametersInfo ... force Windows to update the wallpaper and screen saver information immediately. When you run your application, you'll see the Windows wallpaper bitmap change to the Circles.bmp image -- that is, if you have circles.bmp image in your Windows directory. (Note: your screen saver is now disabled.)

以SystemParametersInfo ...开头的这两行代码强制Windows立即更新墙纸和屏幕保护程序信息。 运行应用程序时,您会看到Windows墙纸位图更改为Circles.bmp图像-也就是说,如果Windows目录中有circle.bmp图像。 (注意:您的屏幕保护程序现已禁用。)

翻译自: https://www.thoughtco.com/working-with-windows-registry-1058474

windows 注册表

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值