notice

致江湖上的朋友:
  欢迎您访问╃苍狼山庄╃请使用侧边栏的搜索功能查找日志,希望能在这里找到您所需要的东西,使您在平淡之中充满喜悦。

Clang 出品,必属精品! 我的地盘我做主! 活着,真累!
本站域名:Http://ClangCN.Com/(点击加入收藏夹)
欢迎您再来,谢谢!!!
Clang 于2006年01月09日

检查某注册表键是否存在的NSIS例子

2009年12月15日 | 分类: 程序代码 | 标签: ,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
; OpenReg.nsi
; 检查某注册表键是否存在的NSIS例子
; 编写:zhfi <zhfi1022@tom.com>
 
;--------------------------------
;定义注册表主键
!define HKEY_CLASSES_ROOT           0x80000000
!define HKEY_CURRENT_USER           0x80000001
!define HKEY_LOCAL_MACHINE          0x80000002
!define HKEY_USERS                  0x80000003
 
OutFile OpenReg.exe
 
XPStyle on
 
!include LogicLib.nsh
 
;--------------------------------
Name OpenReg
 
Section Nil
SectionEnd
 
Function .onInit
;为键的句柄创建一个缓存
System::Call "*(i 0) i .R0"
;将要检测的键放入内存中
Push "SOFTWARE\TENCENT\QQPinYin"
;调用API进行检查,返回值在$R1中
system::call 'Advapi32::RegOpenKey(i ${HKEY_LOCAL_MACHINE}, t s, i R0) .iR1'
;关闭该键的句柄
system::call 'Advapi32::RegCloseKey(i R0)'
;释放内存
system::free
;返回值:
;0代表键存在
;2代表键不存在
;其它值表示出错
${If} $R1 == 0
Messagebox mb_ok "Key Exists!"
${ElseIf} $R1 == 2
Messagebox mb_ok "Key doesn't Exists!"
${Else}
Messagebox mb_ok "Error!"
${EndIf}
Pop $R1
Pop $R0
Quit
FunctionEnd

-------------------------End-------------------------

本文的评论功能被关闭了.