Windows 上で有効
RegCreateKey 関数は特定のレジストリ キーを作成します。 レジストリにキーがすでに存在する場合は、そのキーが開かれます。
このレジストリ操作関数の形式は、以下のとおりです。
RegCreateKey(hKey as Integer, subkey as String) as Integer
現在開いているキーまたは事前定義されたキーを指定します。 hKey パラメータには、すべての Windows プラットフォームで使用可能な事前定義された以下の値を使用できます。
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
開くキーの名前を示す文字列を指定します。 サブキーは、hKey によって指定されたキーのサブキーである必要があります。 subkey パラメーターが空の文字列の場合、この関数は hKey パラメータに指定されたものと同じキーを返します。
正常終了すると、この関数は新しく作成されたレジストリ キーへのハンドルを返します。そうでない場合は、0 を返します。
例: RegCreateKey 関数
Dim hkey1, hkey2, hkey3 as integer
Dim cBuf as string
Dim ccBuf[47] as char
Dim bBuf[100] as byte
Dim i as integer
ClrScr()
for i = 0 to 99
bBuf[i] = i
next i
cBuf = "1234567890sqwertzuiopu+asdfghjkloa#<yxcvbnm,.-"
ccBuf = cBuf
hkey1 = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE")
if hkey1 = 0 then
Print("RegOpenKey failed.")
exit
endif
hkey2 = RegCreateKey(hkey1, "CA Technology")
if hkey2 = 0 then
Print("RegCreateKey 1 failed.")
exit
endif
if Not(RegSetValue(hkey1, "CA", "International")) then
Print("RegSetValue failed")
endif
hkey3 = RegCreateKey(hkey2, "4 test only")
if hkey3 = 0 then
Print("RegCreateKey 2 failed.")
exit
endif
if Not(RegSetVariable(hkey3, "var_1", 123)) then
Print("RegSetVar 1 failed.")
endif
if Not(RegSetVariable(hkey3, "var_2", "i'm a string")) then
Print("RegSetVar 2 failed.")
endif
if Not(RegSetVariable(hkey3, "var_3", cBuf, 46)) then
Print("RegSetVar 3 failed.")
endif
if Not(RegSetVariable(hkey3, "var_4", bBuf, 100)) then
Print("RegSetVar 4 failed.")
endif
if Not(RegSetVariable(hkey3, "var_5", cBuf, 46, REG_SZ)) then
Print("RegSetVar 5 failed.")
endif
if Not(RegSetVariable(hkey3, "var_6", ccBuf, 46, REG_SZ)) then
Print("RegSetVar 5 failed.")
endif
if Not(RegCloseKey(hkey3)) then
Print("RegCloseKey for hkey3 failed.")
endif
if Not(RegCloseKey(hkey2)) then
Print("RegCloseKey for hkey2 failed.")
endif
if Not(RegCloseKey(hkey1)) then
Print("RegCloseKey for hkey1 failed.")
endif
|
Copyright © 2013 CA.
All rights reserved.
|
|