libwin32
Version:
Node bindings to native Win32 DLLs through Koffi
223 lines • 10.7 kB
TypeScript
import { type HKEY } from '../ctypes.js';
import { type SECURITY_ATTRIBUTES, type FILETIME } from '../structs.js';
import { ERROR_, REG_, type REG_OPTION_, type HKEY_, type KEY_, type RRF_ } from '../consts.js';
type LSTATUS = ERROR_;
export interface RegEnumKeyExResult {
name: string;
className: string;
lastWriteTime: FILETIME;
}
export interface RegEnumValueResult {
name: string;
type: REG_;
size: number;
}
export type RegGetValueResult = {
type: REG_.NONE;
value: null;
} | {
type: REG_.SZ;
value: string;
} | {
type: REG_.EXPAND_SZ;
value: string;
} | {
type: REG_.MULTI_SZ;
value: string[];
} | {
type: REG_.BINARY;
value: Uint8Array;
} | {
type: REG_.DWORD;
value: number;
} | {
type: REG_.DWORD_BIG_ENDIAN;
value: number;
} | {
type: REG_.QWORD;
value: BigInt;
} | {
type: REG_;
value: unknown;
};
export interface RegQueryInfoKeyResult {
className: string;
subKeys: number;
values: number;
lastWriteTime: FILETIME;
}
/** Anything that has a `buffer: ArrayBuffer` property: `Buffer`, `TypedArrays`, `DataView`. */
type BufferSource = {
buffer: ArrayBuffer;
byteLength: number;
};
/**
* Closes a handle to the specified registry key.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
*/
export declare function RegCloseKey(hKey: HKEY): LSTATUS;
/**
* Establishes a connection to a predefined registry key on another computer.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regconnectregistryw
*/
export declare function RegConnectRegistry(machineName: string, hKey: HKEY | HKEY_): HKEY | LSTATUS;
/**
* Copies the specified registry key, along with its values and subkeys, to the specified destination key.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regcopytreew
*/
export declare function RegCopyTree(hKeySrc: HKEY | HKEY_, subKey: string | null, hKeyDest: HKEY | HKEY_): LSTATUS;
/**
* Creates the specified registry key. If the key already exists, the function opens it.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regcreatekeyexw
*/
export declare function RegCreateKeyEx(hKey: HKEY | HKEY_, subKey: string, className: string | null, options: REG_OPTION_, samDesired: KEY_, securityAttributes: SECURITY_ATTRIBUTES | null): HKEY | LSTATUS;
/**
* Deletes a subkey and its values.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regdeletekeyw
*/
export declare function RegDeleteKey(hKey: HKEY | HKEY_, subKey: string): LSTATUS;
/**
* Deletes a subkey and its values from the specified platform-specific view of the registry.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regdeletekeyexw
*/
export declare function RegDeleteKeyEx(hKey: HKEY | HKEY_, subKey: string, samDesired: KEY_): LSTATUS;
/**
* Removes the specified value from the specified registry key and subkey.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regdeletekeyvaluew
*/
export declare function RegDeleteKeyValue(hKey: HKEY | HKEY_, subKey?: string | null, valueName?: string | null): LSTATUS;
/**
* Deletes the subkeys and values of the specified key recursively.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regdeletetreew
*/
export declare function RegDeleteTree(hKey: HKEY | HKEY_, subKey?: string | null): LSTATUS;
/**
* Removes a named value from the specified registry key.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regdeletevaluew
*/
export declare function RegDeleteValue(hKey: HKEY | HKEY_, valueName?: string | null): LSTATUS;
/**
* Enumerates the subkeys of the specified open registry key. The function retrieves information about one subkey
* each time it is called.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regenumkeyexw
*/
export declare function RegEnumKeyEx(hKey: HKEY | HKEY_, index: number): RegEnumKeyExResult | LSTATUS;
/**
* Enumerates the values for the specified open registry key.
*
* Note: in libwin32, this function doest not return the value's data, only its type and size (in bytes).
* Use {@link RegGetValue()} to actually read the data.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regenumvaluew
*/
export declare function RegEnumValue(hKey: HKEY | HKEY_, index: number): RegEnumValueResult | LSTATUS;
/**
* Writes all the attributes of the specified open registry key into the registry.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regflushkey
*/
export declare function RegFlushKey(hKey: HKEY | HKEY_): LSTATUS;
/**
* Retrieves the type and data for the specified registry value.
*
* Note: in libwin32, only `REG_NONE`, `REG_SZ`, `REG_EXPAND_SZ`, `REG_MULTI_SZ`,
* `REG_BINARY`, `REG_DWORD`, `REG_DWORD_BIG_ENDIAN` and `REG_QWORD`
* are supported. All other types return `ERROR_UNSUPPORTED`.
*
* `REG_BINARY` values are always returned as a `Uint8Array`.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetvaluew
*/
export declare function RegGetValue(hKey: HKEY | HKEY_, subKey: string | null, value: string | null, flags: RRF_): RegGetValueResult | LSTATUS;
/**
* Loads the specified registry hive as an application hive.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regloadappkeyw
*/
export declare function RegLoadAppKey(file: string, samDesired: KEY_, options: number): HKEY | LSTATUS;
/**
* Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and loads the data from the specified registry hive into that subkey.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regloadkeyw
*/
export declare function RegLoadKey(hKey: HKEY | HKEY_, subKey: string | null, file: string): LSTATUS;
/**
* Opens the specified registry key.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
*/
export declare function RegOpenKeyEx(hKey: HKEY | HKEY_, subKey: string | null, options: REG_OPTION_, samDesired: KEY_): HKEY | LSTATUS;
/**
* Retrieves information about the specified registry key.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryinfokeyw
*/
export declare function RegQueryInfoKey(hKey: HKEY | HKEY_): RegQueryInfoKeyResult | LSTATUS;
/**
* Saves the specified key and all of its subkeys and values to a new file, in the standard format.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsavekeyw
*/
export declare function RegSaveKey(hKey: HKEY | HKEY_, file: string, securityAttributes: SECURITY_ATTRIBUTES): LSTATUS;
/**
* Saves the specified key and all of its subkeys and values to a new file, in the specified format.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsavekeyexw
*/
export declare function RegSaveKeyEx(hKey: HKEY | HKEY_, file: string, securityAttributes: SECURITY_ATTRIBUTES, flags: number): LSTATUS;
/**
* Sets the data for the specified value in the specified registry key and subkey.
*
* Note: in libwin32, only `REG_NONE`, `REG_SZ`, `REG_EXPAND_SZ`, `REG_MULTI_SZ`,
* `REG_BINARY`, `REG_DWORD`, `REG_DWORD_BIG_ENDIAN` and `REG_QWORD`
* are supported. All other types return `ERROR_UNSUPPORTED`.
*
* If the `data` parameter if not of the expected type, then `ERROR_BAD_ARGUMENTS` is returned.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetkeyvaluew
*/
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.NONE, data?: null): LSTATUS;
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.SZ, data: string): LSTATUS;
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.EXPAND_SZ, data: string): LSTATUS;
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.BINARY, data: BufferSource): LSTATUS;
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.DWORD, data: number): LSTATUS;
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.DWORD_BIG_ENDIAN, data: number): LSTATUS;
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.MULTI_SZ, data: string[]): LSTATUS;
export declare function RegSetKeyValue(hKey: HKEY | HKEY_, subKey: string | null, valueName: string | null, type: REG_.QWORD, data: number | bigint): LSTATUS;
/**
* Sets the data and type of a specified value under a registry key.
*
* Note: in libwin32, only `REG_NONE`, `REG_SZ`, `REG_EXPAND_SZ`, `REG_MULTI_SZ`,
* `REG_BINARY`, `REG_DWORD`, `REG_DWORD_BIG_ENDIAN` and `REG_QWORD`
* are supported. All other types return `ERROR_UNSUPPORTED`.
*
* If the `data` parameter if not of the expected type, then `ERROR_BAD_ARGUMENTS` is returned.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetvalueexw
*/
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.NONE, data?: null): LSTATUS;
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.SZ, data: string): LSTATUS;
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.EXPAND_SZ, data: string): LSTATUS;
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.BINARY, data: BufferSource): LSTATUS;
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.DWORD, data: number): LSTATUS;
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.DWORD_BIG_ENDIAN, data: number): LSTATUS;
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.MULTI_SZ, data: string[]): LSTATUS;
export declare function RegSetValueEx(hKey: HKEY | HKEY_, valueName: string | null, type: REG_.QWORD, data: number | bigint): LSTATUS;
/**
* Unloads the specified registry key and its subkeys from the registry.
*
* https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regunloadkeyw
*/
export declare function RegUnLoadKey(hKey: HKEY | HKEY_, subKey: string | null): LSTATUS;
export {};
//# sourceMappingURL=reg.d.ts.map