Questions tagged [windows-rs]

Use this tag for questions specific to the Rust for Windows crate.

Rust for Windows is Microsoft's library providing wrappers for the Win32, COM, and WinRT API surfaces.

36 questions
4
votes
1 answer

Implementing a Windows Credential Provider

I recently discovered the windows-rs framework and have been looking to build a Windows Credential Provider in Rust by implementing their ICredentialProvider COM interface. I've been working on a proof-of-concept implementation using the information…
4
votes
1 answer

How to get a "PCWSTR" object from a Path or String?

I'm using the IDesktopWallpaper::SetWallpaper method from the windows crate. The second argument to this method is a PCWSTR(pointer) to the full path of an image that's meant to be set as the wallpaper. The problem is that the PCWSTR object is meant…
Tony
  • 266
  • 1
  • 11
3
votes
0 answers

Different program behavior when building in release and debug mode

I am trying to read the memory of another process (a dummy program in which a couple of variables are just initialized) using this wrapper over winapi. If I compile this program in debug(cargo build) mode, then the output is true, but everything…
kik3r
  • 41
  • 4
2
votes
1 answer

Can you make a Windows desktop app in Rust and winapi?

I've got a Windows application with a GUI written in Rust and winapi. Despite its GUI, it behaves like a console application. When the exe file is started, a Command Prompt window pops up, and the application is run from it. This is not what I want;…
Kalle Svensson
  • 353
  • 1
  • 10
1
vote
0 answers

Convert a Vec into an IIterable using Rust and windows-rs

I am using Rust and the windows-rs crate to access the Windows API from Rust. As input, I have an Vec which I want to convert into an IIterable. According to this ticket, it should be possible to use the try_from trait. Here is what…
Dominic
  • 4,572
  • 3
  • 25
  • 36
1
vote
1 answer

Why does the Windows crate contain compiled static libraries?

The windows crate, which provides Rust bindings to the Windows API, is split into a few internal crates, one of them being the windows-targets. This create is also split in a few internal crates, and these are loaded according to the target…
rodrigocfd
  • 6,450
  • 6
  • 34
  • 68
1
vote
1 answer

How to get IAudioSessionControl2 in windows-rs?

I'm trying to write a mute.fm-like program in Rust, this is my first big project both using rust and winapi. I managed to get IAudioSessionControl, but it doesn't include process ID or name, so there is no way to know which application it is.…
Lolotronop
  • 21
  • 4
1
vote
1 answer

How should I initialize interface types from the windows crate?

I have a struct that uses some types from the windows crate, but I'm not able to initialize them: use windows::Win32::{ IUIAutomationFocusChangedEventHandler, IUIAutomationFocusChangedEventHandler_Vtbl, }; // Here's my struct: pub struct…
0
votes
1 answer

Open a Key from Windows-Registry (winapi)

Hi i try to open a registry-key with the windows-crate (https://crates.io/crates/windows) unsafe { let hkey: *mut HKEY = ptr::null_mut(); let reg_open_result = windows::Win32::System::Registry::RegOpenKeyExA( …
enno.void
  • 6,242
  • 4
  • 25
  • 42
0
votes
1 answer

Get D3D1211On12 example working using call to D3D11On12CreateDevice

I'm trying to get the C++ D3D1211On12 example working using windows-rs, but I can't get the call to D3D11On12CreateDevice to return a valid ID3D11Device. The code I'm using is: fn create_d11_device(pdevice: &ID3D12Device) -> Result
Shunyata Kharg
  • 927
  • 3
  • 14
  • 26
0
votes
0 answers

Rust window created with CreateWindowExW() does not receive winEventHook messages

So I setup windows hook for EVENT_SYSTEM_FOREGROUND event then in order to receive events from windows there must be message loop in the same thread, this requires setting up a window or using GetMessage()(this is not really an option for this case,…
dalvi
  • 27
  • 5
0
votes
0 answers

Simulating keystrokes does not always work

I am making a streaming bot and I'm trying to have the bot be able to simulate keystrokes/presses, this function works currently in my tests, but for some reason I'm getting complaints that it won't always work or won't work in some…
Jab
  • 26,853
  • 21
  • 75
  • 114
0
votes
1 answer

Rust get executable path of process by window handle or process id

I'm trying to get executable path of process on Windows OS. I have window handle coming from some windows event, from window handle I can acquire process id using GetWindowThreadProcessId(). Then, according to windows api docs I can use…
dalvi
  • 27
  • 5
0
votes
0 answers

Accessing Windows memory Mapped Files from Rust

I'm looking at converted some C++ code to Rust. It needs to use a combination of CreateFileMappingW and MapViewOfFile to access a shared memory segment using the Microsoft Windows API bindings. From C/C++ MapViewOfFile normally returns a pointer to…
0
votes
0 answers

how to listen to events of COM object in rust (windows-rs)

I can use windows-rs to get IDispatch and use it to get prop or call method, but i cannot listen to events. For example, i get a IDispatch 'app', how to listen to it's event 'Close'? I tried IConnectionPointContainer, but failed to define sink…
Xiangshi Yin
  • 31
  • 1
  • 3
1
2 3