Sign in to follow this  

[MDX] Other Application Has Priority Exception

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I finished writing my DirectInput wrapper and to my dismay, it won't allow me to get the input. When I attempt to acquire the device I get this error... "Other Application Has Priority Exception" ... and I'm not too sure why I'm getting this. Here is the relevent parts of my code...
public class cDirectXInput
{

    private MouseState MyMouse;
    private KeyboardState MyKeyboard;
    private Guid MyMouseGuid;
    private Guid MyKeyboardGuid;

    private Device MyKeyboardDevice = null;
    private Device MyMouseDevice = null; 

    private bool[] MyLockedKeys; 


    public cDirectXInput(Control MyTargetControl)
    {
        /* Locked keys means we only see presses instead of press/frame. */
        MyLockedKeys = new bool[256];

        /* Grab the global unique identifer for both the keyboard and the mouse. */
        MyMouseGuid = SystemGuid.Mouse;
        MyKeyboardGuid = SystemGuid.Keyboard;


        /* Create the keyboard and mouse device. */
        MyKeyboardDevice = new Device(MyKeyboardGuid);
        MyMouseDevice = new Device(MyMouseGuid);

        /* Check that it went through. */
        if (MyKeyboardDevice == null /*|| MyMouseDevice == null*/)
            throw new DirectXException("DirectInput Error; you have no control.");

        /* Configure the cooperativity of the devices. */
        MyKeyboardDevice.SetCooperativeLevel(MyTargetControl,
            CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
        MyMouseDevice.SetCooperativeLevel(MyTargetControl,
            CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);

        /* Tell them to start working right away~!*/
        MyKeyboardDevice.Acquire();
        MyMouseDevice.Acquire();
    }
}
At the line...
MyKeyboardDevice.Acquire();
.. the exception is thrown. I'm using this class like so...
public partial class MyWindow : Form
{
    public MyWindow()
    {
        cDirectXInput MyTest = new cDirectXInput(this);
        InitializeComponent();
    }
}
Any ideas?

Share this post


Link to post
Share on other sites
Quote:
Original post by Armadon
Try setting the flags of the device to CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background, this will get rid of your problem.

I hope this helps.
Take care.


Thanks [smile]
ratings++;

Share this post


Link to post
Share on other sites

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this