diff --git a/vlib/os/os_windows.v b/vlib/os/os_windows.v index 7d77002c7e..114977479a 100644 --- a/vlib/os/os_windows.v +++ b/vlib/os/os_windows.v @@ -198,13 +198,14 @@ pub fn get_file_handle(path string) HANDLE { // get_module_filename retrieves the fully qualified path for the file that contains the specified module. // The module must have been loaded by the current process. pub fn get_module_filename(handle HANDLE) ?string { + success := C.SUCCESS unsafe { mut sz := 4096 // Optimized length mut buf := &u16(malloc(4096)) for { status := int(C.GetModuleFileNameW(handle, voidptr(&buf), sz)) match status { - SUCCESS { + success { _filename := string_from_wide2(buf, sz) return _filename }