From d8d3fa204e102672e0b1f38bd9527d7ce41be2a0 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 17 Nov 2021 11:50:34 -0800 Subject: [PATCH] get an actual message box showing --- build.zig | 7 +++---- src/main-windows.zig | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/build.zig b/build.zig index 0cc7931..57f8c9c 100644 --- a/build.zig +++ b/build.zig @@ -19,8 +19,8 @@ pub fn build(b: *std.build.Builder) void { exe.setTarget(target); exe.setBuildMode(mode); - exe.linkLibC(); if (target.getOs().tag == .linux) { + exe.linkLibC(); // LibX11 1.7.2: https://gitlab.freedesktop.org/xorg/lib/libx11/-/archive/libX11-1.7.2/libx11-libX11-1.7.2.tar.gz // LibXfixes 5.0.3: https://gitlab.freedesktop.org/xorg/lib/libxfixes/-/archive/libXfixes-5.0.3/libxfixes-libXfixes-5.0.3.tar.gz // XOrg Proto: https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/archive/xorgproto-2021.5/xorgproto-xorgproto-2021.5.tar.gz @@ -43,9 +43,8 @@ pub fn build(b: *std.build.Builder) void { exe.addObjectFile(obj); } if (target.getOs().tag == .windows) { - // exe.linkLibC(); - // exe.addIncludeDir("/usr/include/"); - // exe.linkSystemLibrary("X11"); + // woah...we don't actually need libc! + exe.linkSystemLibrary("user32"); } exe.install(); diff --git a/src/main-windows.zig b/src/main-windows.zig index 6e06409..2ec9385 100644 --- a/src/main-windows.zig +++ b/src/main-windows.zig @@ -1,10 +1,14 @@ const std = @import("std"); -const win = @cImport({ - @cInclude("windows.h"); -}); -pub fn clipboardAction(watch: bool) !void { - _ = watch; - const stdout = std.io.getStdOut().writer(); - try stdout.print("All your codebase are belong to us", .{}); - try stdout.print("{d}", .{win.HINSTANCE}); +const w = std.os.windows; + +extern "user32" fn MessageBoxA(hWnd: ?w.HANDLE, lpText: ?w.LPCSTR, lpCaption: ?w.LPCSTR, uType: w.UINT) callconv(w.WINAPI) c_int; + +pub export fn wWinMain(hInstance: w.HINSTANCE, hPrevInstance: ?w.HINSTANCE, lpCmdLine: w.PWSTR, nCmdShow: w.INT) w.INT { + _ = hInstance; + _ = hPrevInstance; + _ = lpCmdLine; + _ = nCmdShow; + + _ = MessageBoxA(null, "all your codebase are belong to us", "title", 0); + return 0; }