Skip to content

Commit 179d848

Browse files
committed
Move to dynamic registry editing for simpler Windows use
1 parent f73b24f commit 179d848

File tree

4 files changed

+83
-16
lines changed

4 files changed

+83
-16
lines changed

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ linux:
1818

1919
windows:
2020
mkdir -p output
21-
GOOS=windows go build -o ./build/windows/MultiMC-Twitch.exe
22-
tar -czvf ./output/windows.tar.gz --exclude .gitkeep -C ./build/windows .
21+
GOOS=windows go build -o ./output/MultiMC-Twitch.exe

README.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,17 @@ A simple Go program that handles Twitch's custom protocol and ccip files
55
2. Requests the [TwitchAPI] to get the zip url
66
3. Launches [MultiMC] with the `--import` flag, with the url
77

8-
Examples:
9-
- `MultiMC-Twitch example.ccip`
10-
- `MultiMC-Twitch twitch://www.curseforge.com/minecraft/modpacks/aesthetic-construction/download-client/2246179`
8+
Instructions:
9+
- macOS - Move `MultiMC-Twitch.app` into `Applications`
10+
- Linux - [AUR] or Manually install files into system
11+
- Windows - Move `MultiMC-Twitch.exe` into `MultiMC` folder and execute
1112

12-
Includes:
13-
- Pre-configured Info.plist for handling Twitch protocol
14-
- Pre-configured multimc-twitch.desktop for handling Twitch protocol
15-
- Twitch.reg for handling Twitch protocol (Must be configured)
16-
17-
Configure Twitch.reg for Windows:
18-
1. Edit `Twitch.reg` with any text editor
19-
2. Update the two paths to `MultiMC-Twitch.exe`
20-
(Defaults to C:\MultiMC\MultiMC-Twitch.exe)
21-
3. Run `Twitch.reg`
13+
Note: Having the Twitch app installed may break this.
2214

2315
[Download](https://github.com/ShayBox/MultiMC-CCIP/releases)
2416

2517
[CurseForge]: https://www.curseforge.com/
2618
[Twitch]: https://twitch.tv/
2719
[TwitchAPI]: https://twitchappapi.docs.apiary.io/
28-
[MultiMC]: https://multimc.org/
20+
[MultiMC]: https://multimc.org/
21+
[AUR]: https://aur.archlinux.org/packages/multimc-twitch/

build/windows/Twitch.reg

-728 Bytes
Binary file not shown.

main_windows.go

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"golang.org/x/sys/windows/registry"
8+
)
9+
10+
func init() {
11+
key, _, err := registry.CreateKey(registry.CLASSES_ROOT, "twitch", registry.WRITE)
12+
if err != nil {
13+
fmt.Println(err)
14+
}
15+
16+
defer key.Close()
17+
18+
err = key.SetStringValue("", "URL: Twitch Handler")
19+
if err != nil {
20+
fmt.Println(err)
21+
}
22+
23+
err = key.SetStringValue("URL Protocol", "")
24+
if err != nil {
25+
fmt.Println(err)
26+
}
27+
28+
iconKey, _, err := registry.CreateKey(key, "DefaultIcon", registry.WRITE)
29+
if err != nil {
30+
fmt.Println(err)
31+
}
32+
33+
defer iconKey.Close()
34+
35+
dir, err := os.Getwd()
36+
if err != nil {
37+
fmt.Println(err)
38+
}
39+
40+
err = iconKey.SetStringValue("", dir+"\\MultiMC.exe")
41+
if err != nil {
42+
fmt.Println(err)
43+
}
44+
45+
shellKey, _, err := registry.CreateKey(key, "shell", registry.WRITE)
46+
if err != nil {
47+
fmt.Println(err)
48+
}
49+
50+
defer shellKey.Close()
51+
52+
openKey, _, err := registry.CreateKey(shellKey, "open", registry.WRITE)
53+
if err != nil {
54+
fmt.Println(err)
55+
}
56+
57+
defer openKey.Close()
58+
59+
commandKey, _, err := registry.CreateKey(openKey, "command", registry.WRITE)
60+
if err != nil {
61+
fmt.Println(err)
62+
}
63+
64+
defer commandKey.Close()
65+
66+
executable, err := os.Executable()
67+
if err != nil {
68+
fmt.Println(err)
69+
}
70+
71+
err = commandKey.SetStringValue("", "\""+executable+"\" \"%1\"")
72+
if err != nil {
73+
fmt.Println(err)
74+
}
75+
}

0 commit comments

Comments
 (0)