[System.Runtime.InteropServices.DllImportAttribute("User32.dll", EntryPoint = "BlockInput")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool BlockInput([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fBlockIt);
メインスレッドでブロック入力を実行すると、問題なく実行されます。スレッドに入れて実行すると、true が返されますが、入力はブロックされません。さらに興味深いのは、(最初からではなく) スレッドの内部からコードをデバッグする場合も機能することです。
理由はありますか?すべてのスレッドがメインスレッドの特権を持つべきではありません。ちなみに、管理者権限で実行しています。