How do I use Rundll32 to swapmousebutton?

前端 未结 5 848
没有蜡笔的小新
没有蜡笔的小新 2021-02-06 10:55

I\'m repeating a question from another forum, as I\'d like the same answer.

From MSDN\'s SwapMouseButton Function.

How do I pass boolean data from

5条回答
  •  温柔的废话
    2021-02-06 11:29

    You do not use rundll32 for that.

    Q164787: INFO: Windows Rundll and Rundll32 Interface

    [...] Rundll and Rundll32 programs do not allow you to call any exported function from any DLL. For example, you can not use these utility programs to call the Win32 API (Application Programming Interface) calls exported from the system DLLs. The programs only allow you to call functions from a DLL that are explicitly written to be called by them.


    If you have the .NET Framework Runtime installed, it comes with compilers for several languages (for example, %SystemRoot%\Microsoft.NET\Framework64\v3.5\csc.exe for the v3.5 C# compiler on 64-bit systems). You can write a program in C#:

    using System.Runtime.InteropServices;
    using System;
    
    class SwapMouse {
        [DllImport("user32.dll")]
        public static extern Int32 SwapMouseButton(Int32 bSwap);
        static void Main(string[] args) {
            if (args.Length > 0 && String.Compare(args[0], "/u", true) == 0)
                SwapMouseButton(0);
            else
                SwapMouseButton(1);
        }
    }
    

    Compile with:

    "%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc" swap.cs
    

    Swap/unswap buttons:

    swap
    swap /u
    

提交回复
热议问题