* -------------------------------------------------------------------------
* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* -------------------------------------------------------------------------
*/
#[cfg(windows)]
use std::ffi::CString;
#[cfg(windows)]
use std::fs::read_to_string;
enum HWND__ {}
const MB_ICONERROR: u32 = 0x00000010;
extern "system" {
#[allow(non_snake_case)]
fn MessageBoxA(
hWnd: *mut HWND__,
lpText: *const i8,
lpCaption: *const i8,
uType: u32,
) -> i32;
}
const RUNTIME_URL_CONFIG_PATH: &str = "config/runtime_url_config";
#[cfg(windows)]
pub fn show_webview_err_message() {
let mut runtime_url = String::new();
match read_to_string(RUNTIME_URL_CONFIG_PATH) {
Ok(content) => {
if content.len() > 100 {
return;
}
runtime_url = content
}
Err(e) => eprintln!("read webview2 runtime url config failed: {e}"),
}
let message = format!("Please install from {}", runtime_url);
let title = "Missing Dependencies";
let message = CString::new(message).expect("CString::new failed");
let title = CString::new(title).expect("CString::new failed");
unsafe {
MessageBoxA(
std::ptr::null_mut(),
message.as_ptr(),
title.as_ptr(),
MB_ICONERROR,
);
}
}