This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
any way to use activex dll? #241
Copy link
Copy link
Open
Description
I have a activex dll. Register through:
C:\Windows\SysWOW64\regsvr32.exe TURING.dll
For a long time I have been calling through CreateObject ("TURING.FISR")
in vbs
.
vbs code:
Set TURING = CreateObject("TURING.FISR")
TracePrint TURING.Version() // "x.x.x"
I have no experience with windows api. I have tried the following code:
com::interfaces! {
#[uuid("255A76EC-9167-4034-89DE-06CF1B9930D0")]
pub unsafe interface IidFisrvptr: IUnknown {
pub fn Version(&self) -> com::sys::HRESULT;
}
}
fn main(){
unsafe {
let guid =
windows::Win32::System::Com::CLSIDFromProgID(windows::w!("TURING.FISR")).unwrap();
let clsid = com::IID {
data1: guid.data1,
data2: guid.data2,
data3: guid.data3,
data4: guid.data4,
};
// let ppunk: *mut windows::core::IUnknown;
init_apartment(ApartmentType::SingleThreaded)
.unwrap_or_else(|hr| panic!("Failed to initialize COM Library{:x}", hr));
println!("Initialized apartment");
// Get a `BritishShortHairCat` class factory
let factory = get_class_object::<IClassFactory>(&clsid)
.unwrap_or_else(|hr| panic!("Failed to get cat class object 0x{:x}", hr));
println!("Got cat class object");
// Get an instance of a `BritishShortHairCat` as the `IUnknown` interface
let unknown = factory
.create_instance::<IUnknown>()
.expect("Failed to get IUnknown");
println!("Got IUnknown");
// Now get a handle to the `IAnimal` interface
let fptr = unknown
.query_interface::<IidFisrvptr>()
.expect("Failed to get IAnimal");
println!("Got Version String: {}", fptr.Version()); // "Got Version String: x.x.x"
}
}
get a error:
Initialized apartment
Got cat class object
Got IUnknown
thread 'main' panicked at 'Failed to get IAnimal', src\bin\turing_com\mod.rs:45:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\i686-pc-windows-msvc\debug\server.exe 8001\` (exit code: 101)
i don't know how to get interfaces's uuid, but i got 255A76EC-9167-4034-89DE-06CF1B9930D0
here:
Metadata
Metadata
Assignees
Labels
No labels