Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Support linux
Browse files Browse the repository at this point in the history
  • Loading branch information
rylev authored and MarijnS95 committed Oct 19, 2020
1 parent 3c5fec4 commit 3e0bb9f
Show file tree
Hide file tree
Showing 6 changed files with 1,035 additions and 1,020 deletions.
19 changes: 12 additions & 7 deletions examples/basic/client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use com::{
interfaces::iclass_factory::IClassFactory,
interfaces::iunknown::IUnknown,
runtime::{create_instance, get_class_object, init_apartment, ApartmentType},
};
use interface::{Food, IAnimal, ICat, IDomesticAnimal, IExample, CLSID_CAT_CLASS};

fn main() {
#[cfg(windows)]
run()
}

#[cfg(windows)]
fn run() {
use com::{
interfaces::iclass_factory::IClassFactory,
interfaces::iunknown::IUnknown,
runtime::{create_instance, get_class_object, init_apartment, ApartmentType},
};
use interface::{Food, IAnimal, ICat, IDomesticAnimal, IExample, CLSID_CAT_CLASS};
// Initialize the COM apartment
init_apartment(ApartmentType::SingleThreaded)
.unwrap_or_else(|hr| panic!("Failed to initialize COM Library{:x}", hr));
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(windows)]

mod british_short_hair_cat;

use british_short_hair_cat::BritishShortHairCat;
Expand Down
32 changes: 17 additions & 15 deletions examples/basic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ fn main() {
return;
}

let mut child_proc = Command::new("cmd")
.args(&["/C", "regsvr32 /s ../../target/release/server.dll"])
.spawn()
.expect("Something went wrong!");
if !child_proc.wait().unwrap().success() {
println!("Failed to register server.dll! Make sure you have administrator rights!");
return;
}
if cfg!(windows) {
let mut child_proc = Command::new("cmd")
.args(&["/C", "regsvr32 /s ../../target/release/server.dll"])
.spawn()
.expect("Something went wrong!");
if !child_proc.wait().unwrap().success() {
println!("Failed to register server.dll! Make sure you have administrator rights!");
return;
}

let mut child_proc = Command::new("cmd")
.args(&["/C", "cargo run --release --package client"])
.spawn()
.expect("Something went wrong!");
if !child_proc.wait().unwrap().success() {
println!("Execution of client failed.");
return;
let mut child_proc = Command::new("cmd")
.args(&["/C", "cargo run --release --package client"])
.spawn()
.expect("Something went wrong!");
if !child_proc.wait().unwrap().success() {
println!("Execution of client failed.");
return;
}
}
}
Loading

0 comments on commit 3e0bb9f

Please sign in to comment.