Line data Source code
1 : // Copyright 2026 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'dart:io';
5 :
6 : // Android, iOS, macOS (Info.plist / manifest), Linux (desktop file) and the MSIX package declare the scheme on install.
7 : // The unpackaged Windows build registers it for the current user, pointing at its own executable.
8 0 : Future<void> registerUrlScheme(String scheme) async {
9 0 : if (!Platform.isWindows) {
10 : return;
11 : }
12 0 : final executable = Platform.resolvedExecutable;
13 0 : if (executable.toLowerCase().contains(r'\windowsapps\')) {
14 : return;
15 : }
16 0 : final key = r'HKCU\Software\Classes\' + scheme;
17 0 : for (final arguments in [
18 0 : ['add', key, '/ve', '/d', 'URL:Fingrom', '/f'],
19 0 : ['add', key, '/v', 'URL Protocol', '/d', '', '/f'],
20 0 : ['add', '$key\\shell\\open\\command', '/ve', '/d', '"$executable" "%1"', '/f'],
21 0 : ]) {
22 0 : await Process.run('reg', arguments);
23 : }
24 : }
|