dcli
  • Introduction
  • What does DCli do?
  • Install DCli
    • Installing on Windows
  • Writing your first CLI app
  • Add DCli to your project
  • pub.dev
  • github
  • Dart basics
    • Dart lambda functions
    • Function Arguments
    • Futures
    • stdin/stdout/stderr a primer
  • Tour
    • Overview
    • Using DCli functions
    • User input
      • Ask Validators
    • Displaying information
    • Managing Files And Directories
    • Environment variables
    • Calling apps
    • Redirecting output
    • Command Line Arguments
    • Paths
    • Glob Expansion
    • Piping
    • Locking
    • Fetch
    • The evils of CD
    • Assets/Resources
    • Cross Platform
      • Posix
      • Windows
      • Docker
        • Detecting Docker
        • Add DCli to a Docker Container
        • Example DCli app in Docker
  • Elevated Privileges
    • Sudo
  • Performance
  • Dependency Management
    • Dependency Management
    • Pubspec Managment
  • DCli Tools
    • DCli tools
    • Use a shebang #!
    • DCli Compile
    • DCli Clean
    • DCli Create
    • DCli Doctor
    • DCli Install
    • DCli Run
    • DCli Warmup
    • DCli Pack
    • Upgrade DCli
  • Internal Workings
    • Internal Workings
    • waitForEx
  • Contributing
    • Creating a release
    • Running Unit tests
    • Implemention support for a shell
    • Templates
  • References
  • Examples
    • Projects
    • Code
      • hello world.
      • dcompress
      • dpath
      • dmysql
      • dshell
      • dwhich
      • dipaddr
      • gnome launcher
  • Articles
    • build CLI apps in dart - part 1
    • build CLI apps in dart - part 2
    • Dealing with permissions
    • 3rd Party console packages
  • Dart on Linux - the perfect CLI tooling
  • Improving your build environment
    • Existing tooling
    • Building with Dart
    • A home for your build tools
  • Olivier Revial - CLI apps made easy
  • Video: package of the week
Powered by GitBook
On this page
  • Windows Registry
  • Windows specific functions
  • regAppendToPath
  • regIsOnUserPath
  • regPrependToPath
  • regGetUserPath
  • regSetString
  • regSetNone
  • regGetString
  • regSetDWORD
  • regGetDWORD
  • regDeleteKey
  • regDeleteValue
  • regGetExpandString
  • regSetExpandString
  • regKeyExists
  • regCreateKey

Was this helpful?

  1. Tour
  2. Cross Platform

Windows

PreviousPosixNextDocker

Last updated 2 years ago

Was this helpful?

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

Under the hood DCli uses the 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.

win32