   DirectInput - bad parameters w/ DirectInput8Create
  I purchased a horrible book, or I'm doing something majorly wrong...or my compiler's not compatible with the DirectX 9 SDK...I don't know.I first tried follow the DirectInput instructions in a book...didn't work. So I tried this site:http://www.flipcode.com/cgi-bin/fcarticles.cgi?show=63936But the line:if (DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &lpDInput, NULL) != DI_OK)failed to compile because DirectInputCreate doesn't exist. So I tried the DirectInput8Create version. (essentially the textbook way) It goes:if (FAILED(DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&lpDInput, NULL)))It compiles, runs, then fails at this line. Further investigation told me it was because the parameters were bad.Given the fact I'm having lots of problems no one else is getting, I have to ask...is the DirectX 9 SDK compatible with VC++6? If that's not the problem, why can't I create my device?(lpDInput is of type LPDIRECTINPUT, the book version was of type LPDIRECTINPUT8 and that failed too, for the same reason)   
  First off, DX9 SDK is compatible with Microsoft Visual C++ 6.0, as I have personally tested it. Even if it wasn't, you could still initialize DirectInput8 using some interesting methods or dynamically loading the DLL (shown below). As for your problem It might be your hInstance parameter or the version.I had this problem once when my hInstance was valid, but not technically correct. See MSDN doc on DirectInput8Create():hinstInstance handle to the application or dynamic-link library (DLL) that is creating the DirectInput object. DirectInput uses this value to determine whether the application or DLL has been certified and to establish any special behaviors that might be necessary for backward compatibility. It is an error for a DLL to pass the handle to the parent application. For example, an Microsoft ActiveX control embedded in a Web page that uses DirectInput must pass its own instance handle, and not the handle to the browser. This ensures that DirectInput recognizes the control and can enable any special behaviors that might be necessary.Also, you might want to try explicting #define'ing the DirectInput version to 0x0800 before you #include DirectInput. If you pass a value less than 8.0, this function fails, so sayeth MSDN:dwVersionVersion number of DirectInput for which the application is designed. This value is normally DIRECTINPUT_VERSION. If the application defines DIRECTINPUT_VERSION before including Dinput.h, the value must be greater than 0x0800. For earlier versions, use DirectInputCreateEx, which is in Dinput.lib. //Set version to 8.0#define DIRECTINPUT_VERSION 0x0800In my case, I had a DLL call this function, but I passed my application's WinMain()'s hInstance, and it always failed. In short, the module that is calling this function needs to use ITS hInstance. A simple way of doing this is just to use:GetModuleHandle(NULL).I don't personally like using DirectInput8Create() since then I have to explicitly link to dinput8.dll. I use CoCreateInstance() as so:IDirectInput8* DirectInputCreateViaCOM(){/* Initialize the COM subsystem */HRESULT hr = CoInitialize(NULL);    if(hr != S_OK && hr != S_FALSE)   { return NULL;   }/*This call to CoCreateInstance() will probably fail under WINE..*//* Create an instance of the DirectInput8 object */CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (void**)&pDInput);/* Did this fail to create the DirectInput8 object? */if(pDInput == NULL){/* Uninitialize COM, return false */CoUninitialize();    return NULL;}/* Initialize the object */pDInput->lpVtbl->Initialize(pDInput, GetModuleHandleA(NULL), DIRECTINPUT_VERSION);return pDInput;}Then I need to link to OLE32.dll, but since I need that in other places, this is no problem for me. Hope this helps!;Quote:Original post by FigglesFirst off, DX9 SDK is compatible with Microsoft Visual C++ 6.0, as I have personally tested it.Sort of. Only October 2004 and earlier are compatible with VC6.   