# DirectInput DLL

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

## Recommended Posts

Im trying to create a Direct X Wrapper based on dll , however Ive ran in a problem Whn I try to set the cooperative level I need to get a HWND pointer, which I dont have because Im using a dll. Right now Im using the FindWindow command But If I change the name of my test to anything other than DLL demo it wont work.
  if( FAILED( hr = g_pJoystick->SetCooperativeLevel( FindWindow(NULL, "Dll Demo"), DISCL_EXCLUSIVE |
DISCL_FOREGROUND ) ) )
return hr;

How can I get the HWND of the window that is calling my DLL ?

##### Share on other sites
The most obvious, direct, and recommended approach is to make the caller pass it to the DLL. Additionally, this gives more control to the caller, because he can have many windows, and select one of them and pass it to you.

On a sidenote, if you're writing a wrapper and you're not aiming for cross-platform development (you're using a DLL already...) make it as thin as possible, or re-evaluate your need for a wrapper and drop it altogether if you don't need it. Focus on what you want to get the game done, the input system itself, not wrappers.

##### Share on other sites
Hmm.. good answer thanks, but lets suppose I need to get the Parent HWND is there anyway to do that?

##### Share on other sites
Assuming that you have access to a HWND, then you can always get the parent through the GetParent function.

##### Share on other sites
Quote:
 Original post by AzraelHmm.. good answer thanks, but lets suppose I need to get the Parent HWND is there anyway to do that?

I don't know for sure, but I don't think so. You can't even guarantee there's a HWND; the DLL could be loaded by an application that created no windows.

##### Share on other sites
Try using __declspec(dllimport) to pass things into the dll.

MSDN documentation

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 13
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632927
• Total Posts
3009241
• ### Who's Online (See full list)

There are no registered users currently online

×