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
0
votes
1 answer

How to initialize a data type that doesn't have a default trait (such as IWICBitmapFrameEncode)?

I'm using the windows-rs, the official crate for Windows API. Usually I have no problem with data object initialization, I can use several way to do it, for example: let bitmap = BITMAP::default(); //initialize a BITMAP object or if it's a…
abcjeff
  • 5
  • 4
0
votes
1 answer

EnumProcesses failing to update the Vector

I am trying to enumerate windows processes using the EnumProcesses function provided by Win32 (psapi). Life is smooth, so I am using Rust instead of C++. The code is below. Cargo.toml [dependencies.windows] features = [ "Win32_Foundation", …
Tushar Saurabh
  • 687
  • 2
  • 13
  • 27
0
votes
1 answer

Convert bytes from "OpenSavePidlMRU" into "ITEMIDLIST"

I want to extract a path from the following registry key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU I didn't find any documentation, but it seems that the value contains some IDLIST that can be…
Jerome
  • 15
  • 4
0
votes
2 answers

Binding a Pidl with function BindToObject?

Here is my Rust code: use std::mem::ManuallyDrop; use windows::core::ComInterface; use windows::Win32::System::Com::*; use windows::Win32::UI::Shell::Common::ITEMIDLIST; use windows::{core::Result, Win32::UI::Shell::*}; struct Com; impl Drop for…
Jerome
  • 15
  • 4
0
votes
1 answer

consume COM library from C# to rust

Question I want to rewrite my project from C# to rust. But I stuck in Segmentation Fault situation. I think I misunderstood something, or meet crate limitation, hope for some help. Rust Code find interface UUID regedit capture find CLSID regedit…
G.Jim
  • 1
  • 2
0
votes
1 answer

Convert *mut c_void to HWND

I'm trying to convert a *mut c_void to HWND (https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/Foundation/struct.HWND.html) but it keeps throwing this error: mismatched types expected struct `HWND` found raw pointer `*mut c_void` How…
0
votes
1 answer

DescribePixelFormat from windows crate always returns 0 when given PixelFormat to fill with "parameter is incorrect" (error 87)

I am trying to use the windows crate to set and get the pixel format descriptor of a window. When I pass None to the PPFD parameter, the return value is something reasonable (the maximum pixel format index, it seems). However, when I try to pass it…
Trevor
  • 9
  • 2
  • 5
0
votes
1 answer

Error trying to pass a LPARAM when going through windows

I'm trying to go through all windows (using Windows API) and get a list of the windows, but when I try to pass through a vector as a LPARAM then I get an error: non-primitive cast: *mut Vec as LPARAM an as expression can only be used to…
YummyOreo
  • 15
  • 3
0
votes
0 answers

How to create the main window (UWP/windows-rs)

I am trying to use the UWP capture api Windows.Graphics.Capture to capture a window. For that I have to use the GraphicsCapturePicker to select a screen/window. But I get the error message: Error { code: HRESULT(0x8000000E), message: "Could not…
MEisebitt
  • 122
  • 7
0
votes
1 answer

Not sure how to use IDesktopWallpaper

In the documentation there is a struct 'IDesktopWallpaper' with a method named 'GetWallpaper'. The method takes a reference to 'self' but there is no constructor method for 'IDesktopWallpaper'. use windows::{ core::*, …
Tony
  • 266
  • 1
  • 11
0
votes
0 answers

Shell_NotifyIconA does not display the HICON provided

I am trying to create a simple tray icon using the windows-rs rust crate. When calling Shell_NotifyIconA(NIM_ADD, &data); one is created, however, by default it has a blank image. I have loaded an .ico via LoadImageW, however, still nothing. What am…
Gremious
  • 304
  • 3
  • 10
0
votes
1 answer

How to use HANDLE from windows-rs and rust

I'm trying to call LockFileEx on a std::fs:File and struggle since type HANDLE has multiple implementations: windows::Win32::Foundation::HANDLE std::os::windows::io::BorrowedHandle std::os::windows::raw::HANDLE My current attempt is as follows: fn…
Max Maier
  • 985
  • 6
  • 16
0
votes
1 answer

Get path to selected files in active explorer window

Im trying get the path to the files which are selected in the currently active explorer window. Similar to this example in c# or this example in python. In the internet I found out, that you can use windows-rs to do things with win32. But I only…
Wolffe2
  • 5
  • 3
0
votes
1 answer

windows-rs GetNamedSecurityInfoW error 87

I'm trying to use windows-rs to use GetNamedSecurityInfoW microsoft api docs to read file permission information, but I keep getting error code 87 corresponds to ERROR_INVALID_PARAMETER. What have I done wrong? (I'm not experienced with rust or the…
t348575
  • 674
  • 8
  • 19
0
votes
1 answer

How do you use PostMessage with the windows-rs crate?

I'm new to rust and the windows API and I'm trying to use the PostMessage function using the windows-rs crate. However, I'm not sure what data type WPARAM expects. I've tried guessing since the windows-rs documentation doesn't seem to say. The…
herroh
  • 3
  • 3