Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3493774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:55:28+00:00 2026-05-18T11:55:28+00:00

I want to capture input from joystick using winmm dll .. I don’t have

  • 0

I want to capture input from joystick using winmm dll .. I don’t have much knowledge of importing and working with DLLs.

I tried to do it but i have no idea how to do it ..

[DllImport("winmm.dll")]
public static extern string joyGetPosEx(uint dev, JoyinfoEx ) //Something Similar

How do I get joyinfoEx struct from DLL and put it into JoygetPosEx .. ? :S

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:55:29+00:00Added an answer on May 18, 2026 at 11:55 am

    As your question suggests, you have to import the joyGetPosEx function from wimmm.dll. This is often called P/Invoking because you’re invoking a function out of a native Win32 API (or “platform” DLL). You already know that you need to use that function, so let’s look at it more carefully.

    The documentation for that function indicates that it takes two parameters:

    • The first (uJoyID) is a simple int (or, integer) value that identifies the joystick to be queried.

    • The second (pji) is a little bit more complicated than the first, and I think this is the part you were struggling with. Instead of a standard value type, it is a structure called JOYINFOEX, and you have to define that structure in your code. What the joyGetPosEx function does is fill that special structure with information about the joystick’s position, allowing it to return a bunch of different values all at once. That’s why you have to pass it as a reference (ref), because the function is actually going to fill the instance of the structure that you pass to it with a set of values. Your code can then read those values back out of the variable containing the instance of the structure.

      The documentation for that structure is available here, and it tells you the names and data types
      of each of its members. You can treat a DWORD as an int, so its declaration looks like this:

      [StructLayout(LayoutKind.Sequential)]
      public struct JOYINFOEX 
      {
          public int dwSize; 
          public int dwFlags; 
          public int dwXpos; 
          public int dwYpos; 
          public int dwZpos; 
          public int dwRpos; 
          public int dwUpos; 
          public int dwVpos; 
          public int dwButtons; 
          public int dwButtonNumber; 
          public int dwPOV; 
          public int dwReserved1; 
          public int dwReserved2; 
      }
      

    Finally, the joyGetPosEx function returns a value of type int. This value tells you whether or not the function succeeded, and if it didn’t, what exactly went wrong. It’s an error code. The documentation linked above gives you a table of all the possible values that can be returned. If you want to check against those values, you’ll need to define them as constants in your code:

    public const int JOYERR_BASE = 160
    public const int JOYERR_PARMS = (JOYERR_BASE + 5); 
    public const int JOYERR_UNPLUGGED = (JOYERR_BASE + 7);
    public const int MMSYSERR_BASE = 0;
    public const int MMSYSERR_BADDEVICEID = (MMSYSERR_BASE + 2); 
    public const int MMSYSERR_INVALPARAM = (MMSYSERR_BASE + 11); 
    

    So, given the above, the final function definition looks like this:

    [DllImport("winmm.dll")]
    public static extern int joyGetPosEx(int uJoyID, ref JOYINFOEX pji);
    

    In the future, keep in mind pinvoke.net as a reference for how to define and declare these Win32 API functions in your code. It doesn’t happen to have the joyGetPosEx function (or at least not that I found), but it usually has almost everything you need. And then if that fails, you can do as I tried to explain above: look at the original documentation for the function and try to figure out to define it accordingly to work in .NET.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a url string from which I want to capture all the words
I want to capture the errors from a script into a file instead of
I have a form with a <textarea> and I want to capture any line
I want to use Excel to capture survey results. I want to have a
I want to write C/C++ programs that take input from a MIDI device. The
If all tables I want to delete from have the column gamer_id can i
I want to capture input charcters in text box, convert then according to a
I want to capture a webcam feed using my camera. For that I am
I want to capture the HTTP request header fields, primarily the Referer and User-Agent,
I want to capture the screen in my code to get an image -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.