OPTIONS "WINFUNC NOSOURCE C_CALL"
NUMERIC DIGITS 10
FUNCDEF("RegOpenKeyEx", "32, void, str, 32u, 32u, void stor", 'advapi32')
FUNCDEF("RegCloseKey", "32, void", 'advapi32')
FUNCDEF("RegCreateKeyEx", "32, void, str, 32u, str, 32u, 32u, 32u, void stor, 32u stor", 'advapi32')
FUNCDEF("RegQueryBinary", "32, void, str, void, 32 *, char[260] stor, 32 * dual", 'advapi32', 'RegQueryValueEx')
err = regopenkeyex(2147483650, "SYSTEM\MountedDevices", , 131097, handle)
IF err == 0 THEN DO
valuetype = 3
myvaluesize = 260
err = regquerybinary(handle, "\DosDevices\C:", , valuetype, myvalue, myvaluesize)
IF err \== 0 THEN SAY "Error reading binary value:" err
ELSE DO
SAY "Length of binary data is" myvaluesize "bytes"
myvalue = LEFT(myvalue, myvaluesize)
END
regclosekey(handle)
END
ELSE SAY "Can't open the key:" err
FUNCDEF("RegQueryString", "32, void, str, void, 32 *, str[260] stor, 32 * dual", 'advapi32', 'RegQueryValueEx')
err = regopenkeyex(2147483649, "Software\Reginald", , 131097, handle)
IF err == 0 THEN DO
valuetype = 1
myvaluesize = 260
err = regquerystring(handle, "OPTIONS", , valuetype, myvalue, myvaluesize)
IF err \== 0 THEN SAY "Error reading string value:" err
ELSE SAY "String =" myvalue
CALL regclosekey(handle)
END
ELSE SAY "Can't open the key:" err
FUNCDEF("RegWriteNumber", "32, void, str, 32u, 32u, 32 *, 32u", 'advapi32', 'RegSetValueEx')
err = regcreatekeyex(2147483649, "Software\Reginald", , , , 983103, , handle, result)
IF err == 0 THEN DO
myvalue = 100
err = regwritenumber(handle, "MyValue", , 4, myvalue, 4)
IF err \== 0 THEN SAY "Error writing numeric value:" err
regclosekey(handle)
END
ELSE SAY "Can't open/create the key:" err
FUNCDEF("RegQueryNumber", "32, void, str, void, 32 *, 32 * stor, 32 * dual", 'advapi32', 'RegQueryValueEx')
err = regopenkeyex(2147483649, "Software\Reginald", , 131097, handle)
IF err == 0 THEN DO
valuetype = 4
myvaluesize = 4
err = regquerynumber(handle, "Digits", , valuetype, myvalue, myvaluesize)
IF err \== 0 THEN SAY "Error reading numeric value:" err
ELSE SAY "Number =" myvalue
regclosekey(handle)
END
ELSE SAY "Can't open the key:" err
RETURN
CATCH FAILURE
CONDITION("M") |
|