Do initialization to match windows behavior (with test).

diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index 0190a0c..11c7282 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -303,6 +303,11 @@
         return DSERR_INVALIDPARAM;
     }
 
+    if (This->initialized == FALSE) {
+        WARN("not initialized\n");
+        return DSERR_UNINITIALIZED;
+    }
+
     if (dsbd == NULL) {
         WARN("invalid parameter: dsbd == NULL\n");
         return DSERR_INVALIDPARAM;
@@ -379,6 +384,11 @@
         return DSERR_INVALIDPARAM;
     }
 
+    if (This->initialized == FALSE) {
+        WARN("not initialized\n");
+        return DSERR_UNINITIALIZED;
+    }
+
     if (lpDSCaps == NULL) {
         WARN("invalid parameter: lpDSCaps = NULL\n");
         return DSERR_INVALIDPARAM;
@@ -436,6 +446,11 @@
         return DSERR_INVALIDPARAM;
     }
 
+    if (This->initialized == FALSE) {
+        WARN("not initialized\n");
+        return DSERR_UNINITIALIZED;
+    }
+
     if (psb == NULL) {
         WARN("invalid parameter: psb == NULL\n");
         return DSERR_INVALIDPARAM;
@@ -577,6 +592,11 @@
     ICOM_THIS(IDirectSoundImpl,iface);
     TRACE("(%p, %p)\n",This,lpdwSpeakerConfig);
 
+    if (This->initialized == FALSE) {
+        WARN("not initialized\n");
+        return DSERR_UNINITIALIZED;
+    }
+
     if (lpdwSpeakerConfig == NULL) {
         WARN("invalid parameter: lpdwSpeakerConfig == NULL\n");
         return DSERR_INVALIDPARAM;
@@ -594,6 +614,11 @@
     ICOM_THIS(IDirectSoundImpl,iface);
     TRACE("(%p,0x%08lx)\n",This,config);
 
+    if (This->initialized == FALSE) {
+        WARN("not initialized\n");
+        return DSERR_UNINITIALIZED;
+    }
+
     This->speaker_config = config;
     WARN("not fully functional\n");
     return DS_OK;
@@ -606,6 +631,8 @@
     ICOM_THIS(IDirectSoundImpl,iface);
     TRACE("(%p,%s)\n",This,debugstr_guid(lpcGuid));
 
+    This->initialized = TRUE;
+
     return DS_OK;
 }
 
@@ -616,6 +643,11 @@
     ICOM_THIS(IDirectSoundImpl,iface);
     TRACE("(%p, %p)\n",This,pdwCertified);
 
+    if (This->initialized == FALSE) {
+        WARN("not initialized\n");
+        return DSERR_UNINITIALIZED;
+    }
+
     if (This->drvcaps.dwFlags & DSCAPS_CERTIFIED)
         *pdwCertified = DS_CERTIFIED;
     else
@@ -718,6 +750,7 @@
     pDS->buffers        = NULL;
     pDS->primary        = NULL;
     pDS->speaker_config = DSSPEAKER_STEREO | (DSSPEAKER_GEOMETRY_NARROW << 16);
+    pDS->initialized    = FALSE;
 
     /* 3D listener initial parameters */
     pDS->listener       = NULL;
@@ -1524,22 +1557,7 @@
     return DS_OK;
 }
 
-/*******************************************************************************
- *		DirectSoundCreate (DSOUND.1)
- *
- *  Creates and initializes a DirectSound interface.
- *
- *  PARAMS
- *     lpcGUID   [I] Address of the GUID that identifies the sound device.
- *     ppDS      [O] Address of a variable to receive the interface pointer.
- *     pUnkOuter [I] Must be NULL.
- *
- *  RETURNS
- *     Success: DS_OK
- *     Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
- *              DSERR_NODRIVER, DSERR_OUTOFMEMORY
- */
-HRESULT WINAPI DirectSoundCreate(
+HRESULT WINAPI DSOUND_Create(
     LPCGUID lpcGUID,
     LPDIRECTSOUND *ppDS,
     IUnknown *pUnkOuter)
@@ -1549,6 +1567,11 @@
 
     TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
 
+    if (pUnkOuter != NULL) {
+        WARN("invalid parameter: pUnkOuter != NULL\n");
+        return DSERR_INVALIDPARAM;
+    }
+
     if (ppDS == NULL) {
         WARN("invalid parameter: ppDS == NULL\n");
         return DSERR_INVALIDPARAM;
@@ -1609,9 +1632,9 @@
 }
 
 /*******************************************************************************
- *        DirectSoundCreate8 (DSOUND.11)
+ *		DirectSoundCreate (DSOUND.1)
  *
- *  Creates and initializes a DirectSound8 interface.
+ *  Creates and initializes a DirectSound interface.
  *
  *  PARAMS
  *     lpcGUID   [I] Address of the GUID that identifies the sound device.
@@ -1623,7 +1646,23 @@
  *     Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
  *              DSERR_NODRIVER, DSERR_OUTOFMEMORY
  */
-HRESULT WINAPI DirectSoundCreate8(
+HRESULT WINAPI DirectSoundCreate(
+    LPCGUID lpcGUID,
+    LPDIRECTSOUND *ppDS,
+    IUnknown *pUnkOuter)
+{
+    HRESULT hr;
+
+    TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
+
+    hr = DSOUND_Create(lpcGUID, ppDS, pUnkOuter);
+    if (hr == DS_OK)
+        IDirectSoundImpl_Initialize((LPDIRECTSOUND8)dsound, lpcGUID);
+
+    return hr;
+}
+
+HRESULT WINAPI DSOUND_Create8(
     LPCGUID lpcGUID,
     LPDIRECTSOUND8 *ppDS,
     IUnknown *pUnkOuter)
@@ -1633,6 +1672,11 @@
 
     TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
 
+    if (pUnkOuter != NULL) {
+        WARN("invalid parameter: pUnkOuter != NULL\n");
+        return DSERR_INVALIDPARAM;
+    }
+
     if (ppDS == NULL) {
         WARN("invalid parameter: ppDS == NULL\n");
         return DSERR_INVALIDPARAM;
@@ -1691,3 +1735,34 @@
 
     return hr;
 }
+
+/*******************************************************************************
+ *        DirectSoundCreate8 (DSOUND.11)
+ *
+ *  Creates and initializes a DirectSound8 interface.
+ *
+ *  PARAMS
+ *     lpcGUID   [I] Address of the GUID that identifies the sound device.
+ *     ppDS      [O] Address of a variable to receive the interface pointer.
+ *     pUnkOuter [I] Must be NULL.
+ *
+ *  RETURNS
+ *     Success: DS_OK
+ *     Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
+ *              DSERR_NODRIVER, DSERR_OUTOFMEMORY
+ */
+HRESULT WINAPI DirectSoundCreate8(
+    LPCGUID lpcGUID,
+    LPDIRECTSOUND8 *ppDS,
+    IUnknown *pUnkOuter)
+{
+    HRESULT hr;
+
+    TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID),ppDS,pUnkOuter);
+
+    hr = DSOUND_Create8(lpcGUID, ppDS, pUnkOuter);
+    if (hr == DS_OK)
+        IDirectSoundImpl_Initialize((LPDIRECTSOUND8)dsound, lpcGUID);
+
+    return hr;
+}
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index a1cbb8b..71f7340 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -478,10 +478,10 @@
 	*ppobj = NULL;
 
 	if ( IsEqualIID( &IID_IDirectSound, riid ) )
-		return DirectSoundCreate(0,(LPDIRECTSOUND*)ppobj,pOuter);
+		return DSOUND_Create(0,(LPDIRECTSOUND*)ppobj,pOuter);
 
 	if ( IsEqualIID( &IID_IDirectSound8, riid ) )
-		return DirectSoundCreate8(0,(LPDIRECTSOUND8*)ppobj,pOuter);
+		return DSOUND_Create8(0,(LPDIRECTSOUND8*)ppobj,pOuter);
 
 	WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);	
 	return E_NOINTERFACE;
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 935dfec..7b28c9c 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -95,6 +95,7 @@
     PrimaryBufferImpl*          primary;
     DSBUFFERDESC                dsbd;
     DWORD                       speaker_config;
+    BOOL                        initialized;
 
     /* DirectSound3DListener fields */
     IDirectSound3DListenerImpl*	listener;
@@ -117,6 +118,16 @@
     LPCGUID lpcGUID,
     LPDIRECTSOUND8 * ppds);
 
+HRESULT WINAPI DSOUND_Create(
+    LPCGUID lpcGUID,
+    LPDIRECTSOUND *ppDS,
+    IUnknown *pUnkOuter);
+
+HRESULT WINAPI DSOUND_Create8(
+    LPCGUID lpcGUID,
+    LPDIRECTSOUND8 *ppDS,
+    IUnknown *pUnkOuter);
+
 /*****************************************************************************
  * IDirectSound COM components
  */
diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c
index ff97d22..752edb9 100644
--- a/dlls/dsound/tests/dsound.c
+++ b/dlls/dsound/tests/dsound.c
@@ -69,6 +69,10 @@
         if (rc==DS_OK)
             IDirectSound8_Release(ds8);
 
+        /* try unitialized object */
+        rc=IDirectSound_GetCaps(dso,0);
+        ok(rc==DSERR_UNINITIALIZED,"GetCaps should have returned DSERR_UNINITIALIZED, returned: %s\n",DXGetErrorString9(rc));
+
         rc=IDirectSound_Initialize(dso,NULL);
         ok(rc==DS_OK,"IDirectSound_Initialize(NULL) failed: %s\n",DXGetErrorString9(rc));
 
@@ -171,6 +175,10 @@
         if (rc==DS_OK)
             IDirectSound8_Release(ds8);
 
+        /* try unitialized object */
+        rc=IDirectSound8_GetCaps(dso,0);
+        ok(rc==DSERR_UNINITIALIZED,"GetCaps should have returned DSERR_UNINITIALIZED, returned: %s\n",DXGetErrorString9(rc));
+
         rc=IDirectSound8_Initialize(dso,NULL);
         ok(rc==DS_OK,"IDirectSound_Initialize(NULL) failed: %s\n",DXGetErrorString9(rc));