27 lines
789 B
Dart
Executable File
27 lines
789 B
Dart
Executable File
import 'dart:io';
|
|
|
|
import 'package:rhythm_box/platform.dart';
|
|
import 'package:win32_registry/win32_registry.dart';
|
|
|
|
Future<void> registerWindowsScheme(String scheme) async {
|
|
if (!PlatformInfo.isWindows) return;
|
|
String appPath = Platform.resolvedExecutable;
|
|
|
|
String protocolRegKey = 'Software\\Classes\\$scheme';
|
|
RegistryValue protocolRegValue = const RegistryValue(
|
|
'URL Protocol',
|
|
RegistryValueType.string,
|
|
'',
|
|
);
|
|
String protocolCmdRegKey = 'shell\\open\\command';
|
|
RegistryValue protocolCmdRegValue = RegistryValue(
|
|
'',
|
|
RegistryValueType.string,
|
|
'"$appPath" "%1"',
|
|
);
|
|
|
|
final regKey = Registry.currentUser.createKey(protocolRegKey);
|
|
regKey.createValue(protocolRegValue);
|
|
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
|
|
}
|