tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
78.54k stars 2.33k forks source link

[bug] Programs launched with administrator privileges cannot respond to file drag and drop events #9742

Closed fcode520 closed 3 weeks ago

fcode520 commented 3 weeks ago

Describe the bug

I have a tauri application that can receive file drag and drop messages when launched with standard permissions.

But when I started with administrator privileges, I was unable to receive messages. I followed the implementation method of other applications and proactively modified the Win32 message filter. But still ineffective

mycode

   .setup(| app | {
            let window: Window = app.get_window(MAIN_LABEL).unwrap();
             let hwnd = window.hwnd().expect("Failed to get HWND").0 as *mut _;
            app.listen_global("app-exist",  move |_| app_exist(Some(&window)));
            let success = unsafe { ChangeWindowMessageFilterEx(hwnd, WM_DROPFILES, 1, std::ptr::null_mut()) };
            if success == 0 {
                panic!("Failed to change message filter for WM_DROPFILES");
            }
            let success = unsafe { ChangeWindowMessageFilterEx(hwnd, WM_COPYDATA, 1, std::ptr::null_mut()) };
            if success == 0 {
                panic!("Failed to change message filter for WM_COPYDATA");
            }
            let success = unsafe { ChangeWindowMessageFilterEx(hwnd, 0x0049, 1, std::ptr::null_mut()) };
            if success == 0 {
                panic!("Failed to change message filter for 0x0049");
            }
            Ok(())
        })

What should I do?

Reproduction

No response

Expected behavior

4

Full tauri info output

3

Stack trace

2

Additional context

1

FabianLars commented 3 weeks ago

Duplicate of https://github.com/tauri-apps/tauri/issues/8218