Rust-Windows Interoperability


#1

Continuing the discussion from Rust beginner notes & questions:



Rust beginner notes & questions
#2

winapi is the crate for this. As it is auto-generated, it provides all available APIs.

Well, technically it does. ~3 years ago I played a bit with COM:

Note: com crate is abandoned by me, because a nice and idiomatic implementation will require an enormous amount of time and effort. Also, winapi became so much more useful since then.

Never had problems with UTF-16 personally, through. OsStrings or falling back to some custom wrapper around MultiByteToWideChar / WideCharToMultiByte do the thing.


#3

The central argument in this discussion is shown below. Expand the above linked posts to read further. Be sure to create new linked posts as required.


#4

The central miscommunication there seems to be one part (lack of) ecosystem maturity and two parts a difference of opinion between thin-std+crates vs fat-std, a discussion that has been going on since before Rust-1.0, without making any progress…

Rust makes a radically different choice than other languages, and apparently what the author was trying to do, on windows, aligns very well with the (windows-centric, fat-std,high level, mature) c# language, and less with the (cross-platform/*nix, thin-std, young) Rust language.


#5

winapi is not auto-generated, nor does it provide all available APIs. The goal is to provide all available APIs eventually, but Windows API is just so gosh darn huge.

Calling COM methods is quite easy, because winapi provides inherent methods to call the functions in the vtable, and abstractions like ComPtr make working with COM objects a lot simpler. The more complex COM stuff though is a bit lacking still in Rust.


#6

Ah, okay, thank you for correcting me.