Files
MWClash/lib/common/protocol.dart
chen08209 a8c0519ffe Add rule override
Optimize more details
2025-04-06 20:13:53 +08:00

33 lines
826 B
Dart

import 'dart:io';
import 'package:win32_registry/win32_registry.dart';
class Protocol {
static Protocol? _instance;
Protocol._internal();
factory Protocol() {
_instance ??= Protocol._internal();
return _instance!;
}
void register(String scheme) {
String protocolRegKey = 'Software\\Classes\\$scheme';
RegistryValue protocolRegValue = RegistryValue.string(
'URL Protocol',
'',
);
String protocolCmdRegKey = 'shell\\open\\command';
RegistryValue protocolCmdRegValue = RegistryValue.string(
'',
'"${Platform.resolvedExecutable}" "%1"',
);
final regKey = Registry.currentUser.createKey(protocolRegKey);
regKey.createValue(protocolRegValue);
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
}
}
final protocol = Protocol();