[STI] Sync with Wine Staging 4.18. CORE-16441
[reactos.git] / dll / win32 / sti / sti.c
index d326710..19feadc 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
 #include <stdarg.h>
+#ifdef __REACTOS__
+#include <wchar.h>
+#endif
 
 #define COBJMACROS
 
-#include <windef.h>
-#include <winbase.h>
-#include <winreg.h>
-//#include "winerror.h"
-//#include "objbase.h"
-#include <sti.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winerror.h"
+#include "objbase.h"
+#include "sti.h"
 
-#include <wine/debug.h>
-#include <wine/unicode.h>
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(sti);
 
@@ -48,9 +46,9 @@ static const WCHAR registeredAppsLaunchPath[] = {
 
 typedef struct _stillimage
 {
+    IUnknown IUnknown_inner;
     IStillImageW IStillImageW_iface;
-    IUnknown IUnknown_iface;
-    IUnknown *pUnkOuter;
+    IUnknown *outer_unk;
     LONG ref;
 } stillimage;
 
@@ -63,19 +61,19 @@ static HRESULT WINAPI stillimagew_QueryInterface(IStillImageW *iface, REFIID rii
 {
     stillimage *This = impl_from_IStillImageW(iface);
     TRACE("(%p %s %p)\n", This, debugstr_guid(riid), ppvObject);
-    return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
+    return IUnknown_QueryInterface(This->outer_unk, riid, ppvObject);
 }
 
 static ULONG WINAPI stillimagew_AddRef(IStillImageW *iface)
 {
     stillimage *This = impl_from_IStillImageW(iface);
-    return IUnknown_AddRef(This->pUnkOuter);
+    return IUnknown_AddRef(This->outer_unk);
 }
 
 static ULONG WINAPI stillimagew_Release(IStillImageW *iface)
 {
     stillimage *This = impl_from_IStillImageW(iface);
-    return IUnknown_Release(This->pUnkOuter);
+    return IUnknown_Release(This->outer_unk);
 }
 
 static HRESULT WINAPI stillimagew_Initialize(IStillImageW *iface, HINSTANCE hinst, DWORD dwVersion)
@@ -153,11 +151,11 @@ static HRESULT WINAPI stillimagew_RegisterLaunchApplication(IStillImageW *iface,
     ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, registeredAppsLaunchPath, &registeredAppsKey);
     if (ret == ERROR_SUCCESS)
     {
-        WCHAR *value = HeapAlloc(GetProcessHeap(), 0,
-            (lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1) * sizeof(WCHAR));
+        size_t len = lstrlenW(pwszCommandLine) + 1 + lstrlenW(commandLineSuffix) + 1;
+        WCHAR *value = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
         if (value)
         {
-            sprintfW(value, format, pwszCommandLine, commandLineSuffix);
+            swprintf(value, format, pwszCommandLine, commandLineSuffix);
             ret = RegSetValueExW(registeredAppsKey, pwszAppName, 0,
                 REG_SZ, (BYTE*)value, (lstrlenW(value)+1)*sizeof(WCHAR));
             if (ret != ERROR_SUCCESS)
@@ -265,7 +263,7 @@ static const struct IStillImageWVtbl stillimagew_vtbl =
 
 static inline stillimage *impl_from_IUnknown(IUnknown *iface)
 {
-    return CONTAINING_RECORD(iface, stillimage, IUnknown_iface);
+    return CONTAINING_RECORD(iface, stillimage, IUnknown_inner);
 }
 
 static HRESULT WINAPI Internal_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
@@ -339,18 +337,18 @@ HRESULT WINAPI StiCreateInstanceW(HINSTANCE hinst, DWORD dwVer, PSTIW *ppSti, LP
     if (This)
     {
         This->IStillImageW_iface.lpVtbl = &stillimagew_vtbl;
-        This->IUnknown_iface.lpVtbl = &internal_unk_vtbl;
+        This->IUnknown_inner.lpVtbl = &internal_unk_vtbl;
         if (pUnkOuter)
-            This->pUnkOuter = pUnkOuter;
+            This->outer_unk = pUnkOuter;
         else
-            This->pUnkOuter = &This->IUnknown_iface;
+            This->outer_unk = &This->IUnknown_inner;
         This->ref = 1;
 
         hr = IStillImage_Initialize(&This->IStillImageW_iface, hinst, dwVer);
         if (SUCCEEDED(hr))
         {
             if (pUnkOuter)
-                *ppSti = (IStillImageW*) &This->IUnknown_iface;
+                *ppSti = (IStillImageW*) &This->IUnknown_inner;
             else
                 *ppSti = &This->IStillImageW_iface;
         }