LoginSignup
0
1

More than 5 years have passed since last update.

nim读写注册表的小例子

Posted at

nim读写注册表的小例子
2018年5月7日 15:11:58 codegay

贴一个nim读写注册表的例子,虽然简单,但是nim官方没有写windows注册表相关的文档,
我贴的例子兴许能帮大家省点时间,以下代码是读取计算机描述和设置计算机描述的:

import registry

const path = r"SYSTEM\CurrentControlSet\services\LanmanServer\Parameters"
const key = "srvcomment"

proc getsrvcomment():string {.discardable.} =
    getUnicodeValue(path, key, HKEY_LOCAL_MACHINE)

echo getsrvcomment()


proc setsrvcomment(comment: string) {.discardable.} =
    setUnicodeValue(path, key, val = comment, HKEY_LOCAL_MACHINE)

setsrvcomment("呆瓜小贼 给我上来")

其中 registry 模块是目前nim中自带的,对应是 nim的目录\lib\windows\registry.nim
是一个非常好的学习例子。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1