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 to be of type *const u16
not *const String
. How can I get a PCWSTR
object from a Path/String?
let path = "Path_to_image.jpg".to_string();
let ptr = &path as *const String;
let wallpaper = PCWSTR::from_raw(ptr);
// ^^^ expected raw pointer `*const u16`
// found raw pointer `*const String`
unsafe { desktop.SetWallpaper(None, wallpaper)};