Windows

DCli ships with a number of Windows specific functions and classes.

Under the hood DCli uses the win32 package which we recommend if you need additional Windows specific functionality.

The DCli Windows methods also rely heavily on the win32 package's constants such as HKEY_CURRENT_USER so in most circumstances you will need to import win32.

To add win32 to you dependencies.

pub add win32

To access the Windows specific APIs you need to import the windows barrel file.

import 'package:dcli/windows.dart';
import 'package:win32/win32.dart';

Windows Registry

The Windows Registry is unique to Windows so if you want to write cross platform scripts then you should avoid using the Registry. However in some circumstances this simply isn't possible

In this case use the Platform.isWindows method to determine when to use the registry.

import 'dart:io';
import 'package:dcli/dcli.dart;

void main() {
    if (Plaform.isWindows) {
         regSetString(HKEY_CURRENT_USER, 'Environment', 'PATH_TEST', 'HI');
    }
    else {
    /// do some posix stuff.
    }
}

Windows specific functions

DCli includes:

regAppendToPath

Appends [newPath] to the Windows PATH environment variable.

regIsOnUserPath

Returns true if the given [path] is on the user's path.

regPrependToPath

Prepend [newPath] to the Windows PATH environment variable.

regGetUserPath

Gets the User's Path (as opposed to the system path) as a list.

regSetString

Sets a Windows registry key to a string value of type REG_SZ.

regSetNone

Sets a Windows registry valueName with a type REG_NONE.

regGetString

Gets a Windows registry value o0f type REG_SZ [hkey] is typically HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.

regSetDWORD

Sets a Windows registry key to a string value of type REG_SZ.

regGetDWORD

Reads a DWORD from the registry.

regDeleteKey

Deletes an registry key.

regDeleteValue

Deletes an registry key.

regGetExpandString

Retrieves a registry value located at [hkey]/[subKey]/[valueName] that is of type REG_EXPAND_SZ.

regSetExpandString

Sets the [value] of the [hkey] located at [hkey]/[subKey] in the Windows Registry. The [value] is set to type REG_EXPAND_SZ.

regKeyExists

Tests if a registry key exists.

regCreateKey

Creates a registry key.

Last updated