Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any way to use activex dll? #241

Open
nanchengjiumeng opened this issue Nov 19, 2022 · 0 comments
Open

any way to use activex dll? #241

nanchengjiumeng opened this issue Nov 19, 2022 · 0 comments

Comments

@nanchengjiumeng
Copy link

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:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant