dynamic library - win virtual display

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-11-18 13:33:54 +08:00
parent 4a8578ee85
commit 26e8355528
10 changed files with 91 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ fn build_c_impl() {
if build.get_compiler().is_like_msvc() {
build.define("WIN32", "");
// build.define("_AMD64_", "");
build.flag("-Zi");
build.flag("-Z7");
build.flag("-GR-");
// build.flag("-std:c++11");
} else {

View File

@@ -3,6 +3,10 @@ name = "virtual_display"
version = "0.1.0"
edition = "2021"
[lib]
name = "virtual_display"
crate-type = ["cdylib", "staticlib", "rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]

View File

@@ -13,7 +13,7 @@ fn build_c_impl() {
if build.get_compiler().is_like_msvc() {
build.define("WIN32", "");
build.flag("-Zi");
build.flag("-Z7");
build.flag("-GR-");
// build.flag("-std:c++11");
} else {
@@ -24,7 +24,7 @@ fn build_c_impl() {
}
#[cfg(target_os = "windows")]
build.compile("xxx");
build.compile("win_virtual_display");
#[cfg(target_os = "windows")]
println!("cargo:rerun-if-changed=src/win10/IddController.c");

View File

@@ -11,6 +11,7 @@ lazy_static::lazy_static! {
static ref MONITOR_PLUGIN: Mutex<Vec<u32>> = Mutex::new(Vec::new());
}
#[no_mangle]
pub fn download_driver() -> ResultType<()> {
#[cfg(windows)]
let _download_url = win10::DRIVER_DOWNLOAD_URL;
@@ -22,6 +23,7 @@ pub fn download_driver() -> ResultType<()> {
Ok(())
}
#[no_mangle]
pub fn install_update_driver(_reboot_required: &mut bool) -> ResultType<()> {
#[cfg(windows)]
let install_path = win10::DRIVER_INSTALL_PATH;
@@ -62,6 +64,7 @@ pub fn install_update_driver(_reboot_required: &mut bool) -> ResultType<()> {
Ok(())
}
#[no_mangle]
pub fn uninstall_driver(_reboot_required: &mut bool) -> ResultType<()> {
#[cfg(windows)]
let install_path = win10::DRIVER_INSTALL_PATH;
@@ -96,6 +99,7 @@ pub fn uninstall_driver(_reboot_required: &mut bool) -> ResultType<()> {
Ok(())
}
#[no_mangle]
pub fn is_device_created() -> bool {
#[cfg(windows)]
return *H_SW_DEVICE.lock().unwrap() != 0;
@@ -103,6 +107,7 @@ pub fn is_device_created() -> bool {
return false;
}
#[no_mangle]
pub fn create_device() -> ResultType<()> {
if is_device_created() {
return Ok(());
@@ -120,6 +125,7 @@ pub fn create_device() -> ResultType<()> {
Ok(())
}
#[no_mangle]
pub fn close_device() {
#[cfg(windows)]
unsafe {
@@ -129,6 +135,7 @@ pub fn close_device() {
}
}
#[no_mangle]
pub fn plug_in_monitor() -> ResultType<()> {
#[cfg(windows)]
unsafe {
@@ -149,6 +156,7 @@ pub fn plug_in_monitor() -> ResultType<()> {
Ok(())
}
#[no_mangle]
pub fn plug_out_monitor() -> ResultType<()> {
#[cfg(windows)]
unsafe {
@@ -169,6 +177,7 @@ pub fn plug_out_monitor() -> ResultType<()> {
Ok(())
}
#[no_mangle]
pub fn update_monitor_modes() -> ResultType<()> {
#[cfg(windows)]
unsafe {