Andrew Nguyen : propsys: Implement PSStringFromPropertyKey.
Alexandre Julliard
julliard at winehq.org
Mon Jul 26 13:22:33 CDT 2010
Module: wine
Branch: master
Commit: c50177b1c1706fb6e9d03ee3f3cbcb93cf9813f5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c50177b1c1706fb6e9d03ee3f3cbcb93cf9813f5
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Sun Jul 25 21:57:37 2010 -0500
propsys: Implement PSStringFromPropertyKey.
---
configure | 2 +-
configure.ac | 2 +-
dlls/propsys/Makefile.in | 1 +
dlls/propsys/propsys.spec | 2 +-
dlls/propsys/propsys_main.c | 69 +++++++++++++++++++++++++++++++++++++++++++
include/propsys.idl | 6 ++++
6 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index e6fa900..8f92437 100755
--- a/configure
+++ b/configure
@@ -14664,7 +14664,7 @@ wine_fn_config_test dlls/pdh/tests pdh_test
wine_fn_config_dll pidgen enable_pidgen
wine_fn_config_dll powrprof enable_powrprof powrprof
wine_fn_config_dll printui enable_printui
-wine_fn_config_dll propsys enable_propsys
+wine_fn_config_dll propsys enable_propsys propsys
wine_fn_config_dll psapi enable_psapi psapi
wine_fn_config_test dlls/psapi/tests psapi_test
wine_fn_config_dll pstorec enable_pstorec
diff --git a/configure.ac b/configure.ac
index 68c151f..0180928 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2533,7 +2533,7 @@ WINE_CONFIG_TEST(dlls/pdh/tests)
WINE_CONFIG_DLL(pidgen)
WINE_CONFIG_DLL(powrprof,,[powrprof])
WINE_CONFIG_DLL(printui)
-WINE_CONFIG_DLL(propsys)
+WINE_CONFIG_DLL(propsys,,[propsys])
WINE_CONFIG_DLL(psapi,,[psapi])
WINE_CONFIG_TEST(dlls/psapi/tests)
WINE_CONFIG_DLL(pstorec)
diff --git a/dlls/propsys/Makefile.in b/dlls/propsys/Makefile.in
index 4170751..e217ac4 100644
--- a/dlls/propsys/Makefile.in
+++ b/dlls/propsys/Makefile.in
@@ -3,6 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = propsys.dll
+IMPORTLIB = propsys
C_SRCS = \
propsys_main.c \
diff --git a/dlls/propsys/propsys.spec b/dlls/propsys/propsys.spec
index 1848b47..cd41d90 100644
--- a/dlls/propsys/propsys.spec
+++ b/dlls/propsys/propsys.spec
@@ -91,7 +91,7 @@
@ stub PSRefreshPropertySchema
@ stdcall PSRegisterPropertySchema(wstr)
@ stub PSSetPropertyValue
-@ stub PSStringFromPropertyKey
+@ stdcall PSStringFromPropertyKey(ptr ptr long)
@ stdcall PSUnregisterPropertySchema(wstr)
@ stdcall PropVariantChangeType(ptr ptr long long)
@ stub PropVariantCompareEx
diff --git a/dlls/propsys/propsys_main.c b/dlls/propsys/propsys_main.c
index cdda06d..cd180fe 100644
--- a/dlls/propsys/propsys_main.c
+++ b/dlls/propsys/propsys_main.c
@@ -24,7 +24,10 @@
#include "windef.h"
#include "winbase.h"
+#include "objbase.h"
+#include "propsys.h"
#include "wine/debug.h"
+#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(propsys);
@@ -61,3 +64,69 @@ HRESULT WINAPI PSUnregisterPropertySchema(PCWSTR path)
return E_NOTIMPL;
}
+
+HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz, UINT cch)
+{
+ static const WCHAR guid_fmtW[] = {'{','%','0','8','X','-','%','0','4','X','-',
+ '%','0','4','X','-','%','0','2','X','%','0','2','X','-',
+ '%','0','2','X','%','0','2','X','%','0','2','X',
+ '%','0','2','X','%','0','2','X','%','0','2','X','}',0};
+ static const WCHAR pid_fmtW[] = {'%','u',0};
+
+ WCHAR pidW[PKEY_PIDSTR_MAX + 1];
+ LPWSTR p = psz;
+ int len;
+
+ TRACE("(%p, %p, %u)\n", pkey, psz, cch);
+
+ if (!psz)
+ return E_POINTER;
+
+ /* GUIDSTRING_MAX accounts for null terminator, +1 for space character. */
+ if (cch <= GUIDSTRING_MAX + 1)
+ return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+
+ if (!pkey)
+ {
+ psz[0] = '\0';
+ return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+ }
+
+ sprintfW(psz, guid_fmtW, pkey->fmtid.Data1, pkey->fmtid.Data2,
+ pkey->fmtid.Data3, pkey->fmtid.Data4[0], pkey->fmtid.Data4[1],
+ pkey->fmtid.Data4[2], pkey->fmtid.Data4[3], pkey->fmtid.Data4[4],
+ pkey->fmtid.Data4[5], pkey->fmtid.Data4[6], pkey->fmtid.Data4[7]);
+
+ /* Overwrite the null terminator with the space character. */
+ p += GUIDSTRING_MAX - 1;
+ *p++ = ' ';
+ cch -= GUIDSTRING_MAX - 1 + 1;
+
+ len = sprintfW(pidW, pid_fmtW, pkey->pid);
+
+ if (cch >= len + 1)
+ {
+ strcpyW(p, pidW);
+ return S_OK;
+ }
+ else
+ {
+ WCHAR *ptr = pidW + len - 1;
+
+ psz[0] = '\0';
+ *p++ = '\0';
+ cch--;
+
+ /* Replicate a quirk of the native implementation where the contents
+ * of the property ID string are written backwards to the output
+ * buffer, skipping the rightmost digit. */
+ if (cch)
+ {
+ ptr--;
+ while (cch--)
+ *p++ = *ptr--;
+ }
+
+ return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+ }
+}
diff --git a/include/propsys.idl b/include/propsys.idl
index cc5770e..c098041 100644
--- a/include/propsys.idl
+++ b/include/propsys.idl
@@ -795,6 +795,12 @@ interface ICreateObject : IUnknown
);
}
+cpp_quote("#define PKEY_PIDSTR_MAX 10")
+cpp_quote("#define GUIDSTRING_MAX 39")
+cpp_quote("#define PKEYSTR_MAX (GUIDSTRING_MAX + 1 + PKEY_PIDSTR_MAX)")
+
+cpp_quote("HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY,LPWSTR,UINT);")
+
/* TODO: Add remainder of the C api here */
[
More information about the wine-cvs
mailing list