From a730b04bf1cb01f54452342b1cdd8550dd3b9179 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 5 Apr 2019 13:02:49 +0200 Subject: [PATCH 1/2] Add helpers to launch process and open website. --- core/sys/win32/helpers.odin | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 core/sys/win32/helpers.odin diff --git a/core/sys/win32/helpers.odin b/core/sys/win32/helpers.odin new file mode 100644 index 000000000..8b46dea42 --- /dev/null +++ b/core/sys/win32/helpers.odin @@ -0,0 +1,35 @@ +// +build windows +package win32 + +import "core:strings"; + +call_external_process :: proc(program, command_line: string) -> bool { + + si := Startup_Info{}; + pi := Process_Information{}; + si.cb = size_of(si); + + p := utf8_to_wstring(program); + c := utf8_to_wstring(command_line); + + ret := create_process_w( + p, + c, + nil, + nil, + Bool(false), + u32(0x10), // Create New Console + nil, + nil, + &si, + &pi + ); + return cast(bool)ret; +} + +open_website :: proc(url: string) -> bool { + p :: "C:\\Windows\\System32\\cmd.exe"; + arg := []string{"/C", "start", url}; + args := strings.join(arg, " ", context.temp_allocator); + return call_external_process(p, args); +} \ No newline at end of file From 155b138aa43421489f37f6e76393d1fb8e56480e Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 5 Apr 2019 13:18:50 +0200 Subject: [PATCH 2/2] call_external_process cleanup --- core/sys/win32/helpers.odin | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/core/sys/win32/helpers.odin b/core/sys/win32/helpers.odin index 8b46dea42..fd8b7c3c5 100644 --- a/core/sys/win32/helpers.odin +++ b/core/sys/win32/helpers.odin @@ -4,27 +4,21 @@ package win32 import "core:strings"; call_external_process :: proc(program, command_line: string) -> bool { + si := Startup_Info{ cb=size_of(Startup_Info) }; + pi := Process_Information{}; - si := Startup_Info{}; - pi := Process_Information{}; - si.cb = size_of(si); - - p := utf8_to_wstring(program); - c := utf8_to_wstring(command_line); - - ret := create_process_w( - p, - c, - nil, - nil, - Bool(false), - u32(0x10), // Create New Console - nil, - nil, - &si, - &pi - ); - return cast(bool)ret; + return cast(bool)create_process_w( + utf8_to_wstring(program), + utf8_to_wstring(command_line), + nil, + nil, + Bool(false), + u32(0x10), + nil, + nil, + &si, + &pi + ); } open_website :: proc(url: string) -> bool {