[SHLWAPI_WINETEST]
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 24 Apr 2014 16:07:42 +0000 (16:07 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 24 Apr 2014 16:07:42 +0000 (16:07 +0000)
* Sync with Wine 1.7.17.
CORE-8080

svn path=/trunk/; revision=62956

rostests/winetests/shlwapi/CMakeLists.txt
rostests/winetests/shlwapi/assoc.c
rostests/winetests/shlwapi/clist.c
rostests/winetests/shlwapi/clsid.c
rostests/winetests/shlwapi/istream.c
rostests/winetests/shlwapi/ordinal.c
rostests/winetests/shlwapi/path.c
rostests/winetests/shlwapi/shreg.c
rostests/winetests/shlwapi/string.c
rostests/winetests/shlwapi/url.c

index b08ce3c..9d7d798 100644 (file)
@@ -18,5 +18,8 @@ list(APPEND SOURCE
 add_executable(shlwapi_winetest ${SOURCE})
 target_link_libraries(shlwapi_winetest uuid)
 set_module_type(shlwapi_winetest win32cui)
-add_importlibs(shlwapi_winetest shlwapi ole32 oleaut32 user32 advapi32 msvcrt kernel32 ntdll)
+add_importlibs(shlwapi_winetest shlwapi ole32 oleaut32 user32 advapi32 msvcrt kernel32)
+if(MSVC)
+    add_importlibs(shlwapi_winetest ntdll)
+endif()
 add_cd_file(TARGET shlwapi_winetest DESTINATION reactos/bin FOR all)
index 36f8b4f..0b3b4fa 100644 (file)
@@ -44,6 +44,8 @@ static const WCHAR invalid[] = { 'i','n','v','a','l','i','d',0 };
 
 static void test_getstring_bad(void)
 {
+    static const WCHAR openwith[] = {'O','p','e','n','W','i','t','h','.','e','x','e',0};
+    WCHAR buf[MAX_PATH];
     HRESULT hr;
     DWORD len;
 
@@ -53,47 +55,71 @@ static void test_getstring_bad(void)
         return;
     }
 
+    len = 0xdeadbeef;
     hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, NULL, open, NULL, &len);
     expect_hr(E_INVALIDARG, hr);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+
+    len = 0xdeadbeef;
     hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, badBad, open, NULL, &len);
     ok(hr == E_FAIL ||
        hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION), /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
        "Unexpected result : %08x\n", hr);
-    hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, NULL, &len);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+
+    len = sizeof(buf)/sizeof(buf[0]);
+    hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, buf, &len);
     ok(hr == E_FAIL ||
-       hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION), /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
+       hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */ ||
+       hr == S_OK /* Win8 */,
        "Unexpected result : %08x\n", hr);
-    hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, invalid, NULL,
-                           &len);
+    if (hr == S_OK)
+    {
+        ok(len < sizeof(buf)/sizeof(buf[0]), "got %u\n", len);
+        ok(!lstrcmpiW(buf + len - sizeof(openwith)/sizeof(openwith[0]), openwith), "wrong data\n");
+    }
+
+    len = 0xdeadbeef;
+    hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, invalid, NULL, &len);
     ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
        hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION), /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
        "Unexpected result : %08x\n", hr);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+
     hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, NULL);
     ok(hr == E_UNEXPECTED ||
        hr == E_INVALIDARG, /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
        "Unexpected result : %08x\n", hr);
 
+    len = 0xdeadbeef;
     hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, NULL, open, NULL, &len);
     expect_hr(E_INVALIDARG, hr);
-    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, badBad, open, NULL,
-                           &len);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+
+    len = 0xdeadbeef;
+    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, badBad, open, NULL, &len);
     ok(hr == E_FAIL ||
        hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION), /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
        "Unexpected result : %08x\n", hr);
-    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotBad, open, NULL,
-                           &len);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+
+    len = 0xdeadbeef;
+    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotBad, open, NULL, &len);
     ok(hr == E_FAIL ||
        hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */ ||
        hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND), /* Win8 */
        "Unexpected result : %08x\n", hr);
-    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL,
-                           &len);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+
+    len = 0xdeadbeef;
+    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL, &len);
     ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
        hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) || /* W2K/Vista/W2K8 */
        hr == E_FAIL, /* Win9x/WinMe/NT4 */
        "Unexpected result : %08x\n", hr);
-    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
-                           NULL);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+
+    hr = pAssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL, NULL);
     ok(hr == E_UNEXPECTED ||
        hr == E_INVALIDARG, /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */
        "Unexpected result : %08x\n", hr);
index 1816836..438f605 100755 (executable)
@@ -21,6 +21,8 @@
 #define _INC_WINDOWS
 #define COM_NO_WINDOWS_H
 
+#define COBJMACROS
+
 //#include <stdarg.h>
 
 #include <wine/test.h>
@@ -54,9 +56,9 @@ static const SHLWAPI_CLIST SHLWAPI_CLIST_items[] =
 };
 
 /* Dummy IStream object for testing calls */
-typedef struct
+struct dummystream
 {
-  void* lpVtbl;
+  IStream IStream_iface;
   LONG  ref;
   int   readcalls;
   BOOL  failreadcall;
@@ -71,30 +73,45 @@ typedef struct
   BOOL  failstatcall;
   LPCSHLWAPI_CLIST item;
   ULARGE_INTEGER   pos;
-} _IDummyStream;
+};
 
-static
-HRESULT WINAPI QueryInterface(_IDummyStream *This,REFIID riid, LPVOID *ppvObj)
+static inline struct dummystream *impl_from_IStream(IStream *iface)
 {
-  return S_OK;
+    return CONTAINING_RECORD(iface, struct dummystream, IStream_iface);
 }
 
-static ULONG WINAPI AddRef(_IDummyStream *This)
+static HRESULT WINAPI QueryInterface(IStream *iface, REFIID riid, void **ret_iface)
 {
-  return InterlockedIncrement(&This->ref);
+    if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IStream, riid)) {
+        *ret_iface = iface;
+        IStream_AddRef(iface);
+        return S_OK;
+    }
+    trace("Unexpected REFIID %s\n", wine_dbgstr_guid(riid));
+    *ret_iface = NULL;
+    return E_NOINTERFACE;
 }
 
-static ULONG WINAPI Release(_IDummyStream *This)
+static ULONG WINAPI AddRef(IStream *iface)
 {
-  return InterlockedDecrement(&This->ref);
+    struct dummystream *This = impl_from_IStream(iface);
+
+    return InterlockedIncrement(&This->ref);
 }
 
-static HRESULT WINAPI Read(_IDummyStream* This, LPVOID lpMem, ULONG ulSize,
-                           PULONG lpRead)
+static ULONG WINAPI Release(IStream *iface)
 {
+    struct dummystream *This = impl_from_IStream(iface);
+
+    return InterlockedDecrement(&This->ref);
+}
+
+static HRESULT WINAPI Read(IStream *iface, void *lpMem, ULONG ulSize, ULONG *lpRead)
+{
+  struct dummystream *This = impl_from_IStream(iface);
   HRESULT hRet = S_OK;
-  ++This->readcalls;
 
+  ++This->readcalls;
   if (This->failreadcall)
   {
     return STG_E_ACCESSDENIED;
@@ -140,9 +157,9 @@ static HRESULT WINAPI Read(_IDummyStream* This, LPVOID lpMem, ULONG ulSize,
   return hRet;
 }
 
-static HRESULT WINAPI Write(_IDummyStream* This, LPVOID lpMem, ULONG ulSize,
-                            PULONG lpWritten)
+static HRESULT WINAPI Write(IStream *iface, const void *lpMem, ULONG ulSize, ULONG *lpWritten)
 {
+  struct dummystream *This = impl_from_IStream(iface);
   HRESULT hRet = S_OK;
 
   ++This->writecalls;
@@ -159,9 +176,11 @@ static HRESULT WINAPI Write(_IDummyStream* This, LPVOID lpMem, ULONG ulSize,
   return hRet;
 }
 
-static HRESULT WINAPI Seek(_IDummyStream* This, LARGE_INTEGER dlibMove,
-                           DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
+static HRESULT WINAPI Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin,
+        ULARGE_INTEGER *plibNewPosition)
 {
+  struct dummystream *This = impl_from_IStream(iface);
+
   ++This->seekcalls;
   This->pos.QuadPart = dlibMove.QuadPart;
   if (plibNewPosition)
@@ -169,9 +188,10 @@ static HRESULT WINAPI Seek(_IDummyStream* This, LARGE_INTEGER dlibMove,
   return S_OK;
 }
 
-static HRESULT WINAPI Stat(_IDummyStream* This, STATSTG* pstatstg,
-                           DWORD grfStatFlag)
+static HRESULT WINAPI Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 {
+  struct dummystream *This = impl_from_IStream(iface);
+
   ++This->statcalls;
   if (This->failstatcall)
     return E_FAIL;
@@ -181,7 +201,7 @@ static HRESULT WINAPI Stat(_IDummyStream* This, STATSTG* pstatstg,
 }
 
 /* VTable */
-static void* iclvt[] =
+static IStreamVtbl iclvt =
 {
   QueryInterface,
   AddRef,
@@ -206,14 +226,14 @@ static VOID    (WINAPI *pSHLWAPI_19)(LPSHLWAPI_CLIST);
 static HRESULT (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST);
 static BOOL    (WINAPI *pSHLWAPI_21)(LPSHLWAPI_CLIST*,ULONG);
 static LPSHLWAPI_CLIST (WINAPI *pSHLWAPI_22)(LPSHLWAPI_CLIST,ULONG);
-static HRESULT (WINAPI *pSHLWAPI_17)(_IDummyStream*,LPSHLWAPI_CLIST);
-static HRESULT (WINAPI *pSHLWAPI_18)(_IDummyStream*,LPSHLWAPI_CLIST*);
+static HRESULT (WINAPI *pSHLWAPI_17)(IStream*, SHLWAPI_CLIST*);
+static HRESULT (WINAPI *pSHLWAPI_18)(IStream*, SHLWAPI_CLIST**);
 
-static BOOL    (WINAPI *pSHLWAPI_166)(_IDummyStream*);
-static HRESULT (WINAPI *pSHLWAPI_184)(_IDummyStream*,LPVOID,ULONG);
-static HRESULT (WINAPI *pSHLWAPI_212)(_IDummyStream*,LPCVOID,ULONG);
-static HRESULT (WINAPI *pSHLWAPI_213)(_IDummyStream*);
-static HRESULT (WINAPI *pSHLWAPI_214)(_IDummyStream*,ULARGE_INTEGER*);
+static BOOL    (WINAPI *pSHLWAPI_166)(IStream*);
+static HRESULT (WINAPI *pSHLWAPI_184)(IStream*, void*, ULONG);
+static HRESULT (WINAPI *pSHLWAPI_212)(IStream*, const void*, ULONG);
+static HRESULT (WINAPI *pSHLWAPI_213)(IStream*);
+static HRESULT (WINAPI *pSHLWAPI_214)(IStream*, ULARGE_INTEGER*);
 
 
 static BOOL InitFunctionPtrs(void)
@@ -252,29 +272,29 @@ static BOOL InitFunctionPtrs(void)
   return TRUE;
 }
 
-static void InitDummyStream(_IDummyStream* iface)
+static void InitDummyStream(struct dummystream *obj)
 {
-  iface->lpVtbl = (void*)iclvt;
-  iface->ref = 1;
-  iface->readcalls = 0;
-  iface->failreadcall = FALSE;
-  iface->failreadsize = FALSE;
-  iface->readbeyondend = FALSE;
-  iface->readreturnlarge = FALSE;
-  iface->writecalls = 0;
-  iface->failwritecall = FALSE;
-  iface->failwritesize = FALSE;
-  iface->seekcalls = 0;
-  iface->statcalls = 0;
-  iface->failstatcall = FALSE;
-  iface->item = SHLWAPI_CLIST_items;
-  iface->pos.QuadPart = 0;
+    obj->IStream_iface.lpVtbl = &iclvt;
+    obj->ref = 1;
+    obj->readcalls = 0;
+    obj->failreadcall = FALSE;
+    obj->failreadsize = FALSE;
+    obj->readbeyondend = FALSE;
+    obj->readreturnlarge = FALSE;
+    obj->writecalls = 0;
+    obj->failwritecall = FALSE;
+    obj->failwritesize = FALSE;
+    obj->seekcalls = 0;
+    obj->statcalls = 0;
+    obj->failstatcall = FALSE;
+    obj->item = SHLWAPI_CLIST_items;
+    obj->pos.QuadPart = 0;
 }
 
 
 static void test_CList(void)
 {
-  _IDummyStream streamobj;
+  struct dummystream streamobj;
   LPSHLWAPI_CLIST list = NULL;
   LPCSHLWAPI_CLIST item = SHLWAPI_CLIST_items;
   HRESULT hRet;
@@ -342,7 +362,7 @@ static void test_CList(void)
   /* Write the list */
   InitDummyStream(&streamobj);
 
-  hRet = pSHLWAPI_17(&streamobj, list);
+  hRet = pSHLWAPI_17(&streamobj.IStream_iface, list);
   ok(hRet == S_OK, "write failed\n");
   if (hRet == S_OK)
   {
@@ -356,7 +376,7 @@ static void test_CList(void)
   /* Failure cases for writing */
   InitDummyStream(&streamobj);
   streamobj.failwritecall = TRUE;
-  hRet = pSHLWAPI_17(&streamobj, list);
+  hRet = pSHLWAPI_17(&streamobj.IStream_iface, list);
   ok(hRet == STG_E_ACCESSDENIED, "changed object failure return\n");
   ok(streamobj.writecalls == 1, "called object after failure\n");
   ok(streamobj.readcalls == 0,"called Read() after failure\n");
@@ -364,7 +384,7 @@ static void test_CList(void)
 
   InitDummyStream(&streamobj);
   streamobj.failwritesize = TRUE;
-  hRet = pSHLWAPI_17(&streamobj, list);
+  hRet = pSHLWAPI_17(&streamobj.IStream_iface, list);
   ok(hRet == STG_E_MEDIUMFULL || broken(hRet == E_FAIL) /* Win7 */,
      "changed size failure return\n");
   ok(streamobj.writecalls == 1, "called object after size failure\n");
@@ -412,7 +432,7 @@ static void test_CList(void)
   /* Create a list by reading in data */
   InitDummyStream(&streamobj);
 
-  hRet = pSHLWAPI_18(&streamobj, &list);
+  hRet = pSHLWAPI_18(&streamobj.IStream_iface, &list);
   ok(hRet == S_OK, "failed create from Read()\n");
   if (hRet == S_OK)
   {
@@ -465,7 +485,7 @@ static void test_CList(void)
   /* Failure cases for reading */
   InitDummyStream(&streamobj);
   streamobj.failreadcall = TRUE;
-  hRet = pSHLWAPI_18(&streamobj, &list);
+  hRet = pSHLWAPI_18(&streamobj.IStream_iface, &list);
   ok(hRet == STG_E_ACCESSDENIED, "changed object failure return\n");
   ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
   ok(streamobj.readcalls == 1, "called object after read failure\n");
@@ -475,7 +495,7 @@ static void test_CList(void)
   /* Read returns large object */
   InitDummyStream(&streamobj);
   streamobj.readreturnlarge = TRUE;
-  hRet = pSHLWAPI_18(&streamobj, &list);
+  hRet = pSHLWAPI_18(&streamobj.IStream_iface, &list);
   ok(hRet == S_OK, "failed create from Read() with large item\n");
   ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
   ok(streamobj.readcalls == 1,"wrong call count\n");
@@ -487,14 +507,14 @@ static void test_CList(void)
 
 static BOOL test_SHLWAPI_166(void)
 {
-  _IDummyStream streamobj;
+  struct dummystream streamobj;
   BOOL bRet;
 
   if (!pSHLWAPI_166)
     return FALSE;
 
   InitDummyStream(&streamobj);
-  bRet = pSHLWAPI_166(&streamobj);
+  bRet = pSHLWAPI_166(&streamobj.IStream_iface);
 
   if (bRet != TRUE)
     return FALSE; /* This version doesn't support stream ops on clists */
@@ -507,7 +527,7 @@ static BOOL test_SHLWAPI_166(void)
   streamobj.statcalls = 0;
   streamobj.pos.QuadPart = 50001;
 
-  bRet = pSHLWAPI_166(&streamobj);
+  bRet = pSHLWAPI_166(&streamobj.IStream_iface);
 
   ok(bRet == FALSE, "failed after seek adjusted\n");
   ok(streamobj.readcalls == 0, "called Read()\n");
@@ -519,7 +539,7 @@ static BOOL test_SHLWAPI_166(void)
   InitDummyStream(&streamobj);
   streamobj.pos.QuadPart = 50001;
   streamobj.failstatcall = TRUE; /* 1: Stat() Bad, Read() OK */
-  bRet = pSHLWAPI_166(&streamobj);
+  bRet = pSHLWAPI_166(&streamobj.IStream_iface);
   ok(bRet == FALSE, "should be FALSE after read is OK\n");
   ok(streamobj.readcalls == 1, "wrong call count\n");
   ok(streamobj.writecalls == 0, "called Write()\n");
@@ -531,7 +551,7 @@ static BOOL test_SHLWAPI_166(void)
   streamobj.pos.QuadPart = 50001;
   streamobj.failstatcall = TRUE;
   streamobj.failreadcall = TRUE; /* 2: Stat() Bad, Read() Bad Also */
-  bRet = pSHLWAPI_166(&streamobj);
+  bRet = pSHLWAPI_166(&streamobj.IStream_iface);
   ok(bRet == TRUE, "Should be true after read fails\n");
   ok(streamobj.readcalls == 1, "wrong call count\n");
   ok(streamobj.writecalls == 0, "called Write()\n");
@@ -543,7 +563,7 @@ static BOOL test_SHLWAPI_166(void)
 
 static void test_SHLWAPI_184(void)
 {
-  _IDummyStream streamobj;
+  struct dummystream streamobj;
   char buff[256];
   HRESULT hRet;
 
@@ -551,7 +571,7 @@ static void test_SHLWAPI_184(void)
     return;
 
   InitDummyStream(&streamobj);
-  hRet = pSHLWAPI_184(&streamobj, buff, sizeof(buff));
+  hRet = pSHLWAPI_184(&streamobj.IStream_iface, buff, sizeof(buff));
 
   ok(hRet == S_OK, "failed Read()\n");
   ok(streamobj.readcalls == 1, "wrong call count\n");
@@ -561,7 +581,7 @@ static void test_SHLWAPI_184(void)
 
 static void test_SHLWAPI_212(void)
 {
-  _IDummyStream streamobj;
+  struct dummystream streamobj;
   char buff[256];
   HRESULT hRet;
 
@@ -569,7 +589,7 @@ static void test_SHLWAPI_212(void)
     return;
 
   InitDummyStream(&streamobj);
-  hRet = pSHLWAPI_212(&streamobj, buff, sizeof(buff));
+  hRet = pSHLWAPI_212(&streamobj.IStream_iface, buff, sizeof(buff));
 
   ok(hRet == S_OK, "failed Write()\n");
   ok(streamobj.readcalls == 0, "called Read()\n");
@@ -579,7 +599,7 @@ static void test_SHLWAPI_212(void)
 
 static void test_SHLWAPI_213(void)
 {
-  _IDummyStream streamobj;
+  struct dummystream streamobj;
   ULARGE_INTEGER ul;
   LARGE_INTEGER ll;
   HRESULT hRet;
@@ -589,24 +609,24 @@ static void test_SHLWAPI_213(void)
 
   InitDummyStream(&streamobj);
   ll.QuadPart = 5000l;
-  Seek(&streamobj, ll, 0, NULL); /* Seek to 5000l */
+  Seek(&streamobj.IStream_iface, ll, 0, NULL); /* Seek to 5000l */
 
   streamobj.seekcalls = 0;
-  pSHLWAPI_213(&streamobj); /* Should rewind */
+  pSHLWAPI_213(&streamobj.IStream_iface); /* Should rewind */
   ok(streamobj.statcalls == 0, "called Stat()\n");
   ok(streamobj.readcalls == 0, "called Read()\n");
   ok(streamobj.writecalls == 0, "called Write()\n");
   ok(streamobj.seekcalls == 1, "wrong call count\n");
 
   ul.QuadPart = 50001;
-  hRet = pSHLWAPI_214(&streamobj, &ul);
+  hRet = pSHLWAPI_214(&streamobj.IStream_iface, &ul);
   ok(hRet == S_OK, "failed Stat()\n");
   ok(ul.QuadPart == 0, "213 didn't rewind stream\n");
 }
 
 static void test_SHLWAPI_214(void)
 {
-  _IDummyStream streamobj;
+  struct dummystream streamobj;
   ULARGE_INTEGER ul;
   LARGE_INTEGER ll;
   HRESULT hRet;
@@ -616,10 +636,10 @@ static void test_SHLWAPI_214(void)
 
   InitDummyStream(&streamobj);
   ll.QuadPart = 5000l;
-  Seek(&streamobj, ll, 0, NULL);
+  Seek(&streamobj.IStream_iface, ll, 0, NULL);
   ul.QuadPart = 0;
   streamobj.seekcalls = 0;
-  hRet = pSHLWAPI_214(&streamobj, &ul);
+  hRet = pSHLWAPI_214(&streamobj.IStream_iface, &ul);
 
   ok(hRet == S_OK, "failed Stat()\n");
   ok(streamobj.statcalls == 1, "wrong call count\n");
index f606731..afad9ae 100755 (executable)
@@ -112,7 +112,7 @@ static void test_ClassIDs(void)
   DWORD dwLen;
   BOOL bRet;
   int i = 0;
-  int is_vista = 0;
+  BOOL is_vista = FALSE;
 
   if (!pSHLWAPI_269 || !pSHLWAPI_23)
     return;
@@ -120,7 +120,7 @@ static void test_ClassIDs(void)
   while (*guids)
   {
     dwLen = pSHLWAPI_23(*guids, szBuff, 256);
-    if (!i && dwLen == S_OK) is_vista = 1;  /* seems to return an HRESULT on vista */
+    if (!i && dwLen == S_OK) is_vista = TRUE;  /* seems to return an HRESULT on vista */
     ok(dwLen == (is_vista ? S_OK : 39), "wrong size %u for id %d\n", dwLen, i);
 
     bRet = pSHLWAPI_269(szBuff, &guid);
index 65cc66c..bf116b3 100644 (file)
@@ -41,6 +41,7 @@ static HRESULT (WINAPI *pSHCreateStreamOnFileA)(LPCSTR file, DWORD mode, IStream
 static HRESULT (WINAPI *pSHCreateStreamOnFileW)(LPCWSTR file, DWORD mode, IStream **stream);
 static HRESULT (WINAPI *pSHCreateStreamOnFileEx)(LPCWSTR file, DWORD mode, DWORD attributes, BOOL create, IStream *template, IStream **stream);
 
+static BOOL is_win2000_IE5 = FALSE;
 
 static void test_IStream_invalid_operations(IStream * stream, DWORD mode)
 {
@@ -82,40 +83,53 @@ static void test_IStream_invalid_operations(IStream * stream, DWORD mode)
 
     ret = stream->lpVtbl->Write(stream, NULL, 0, &count);
     if (mode == STGM_READ)
-        ok(ret == STG_E_ACCESSDENIED /* XP */ || ret == S_OK /* 2000 */,
-           "expected STG_E_ACCESSDENIED or S_OK, got 0x%08x\n", ret);
+    {
+        ok(ret == STG_E_ACCESSDENIED /* XP */ || broken(ret == S_OK) /* Win2000 + IE5 */,
+           "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret);
+        if (ret == S_OK)
+            is_win2000_IE5 = TRUE;
+    }
     else
         ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret);
 
+    /* IStream::Write calls below hang under Win2000 + IE5, Win2000 + IE6 SP1
+     * and newer Windows versions pass these tests.
+     */
+    if (is_win2000_IE5)
+    {
+        win_skip("broken IStream::Write implementation (win2000)\n");
+        return;
+    }
+
     strcpy(data, "Hello");
     ret = stream->lpVtbl->Write(stream, data, 5, NULL);
     if (mode == STGM_READ)
-        ok(ret == STG_E_ACCESSDENIED /* XP */ || ret == S_OK /* 2000 */,
-           "expected STG_E_ACCESSDENIED or S_OK, got 0x%08x\n", ret);
+        ok(ret == STG_E_ACCESSDENIED,
+           "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret);
     else
         ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret);
 
     strcpy(data, "Hello");
     ret = stream->lpVtbl->Write(stream, data, 0, NULL);
     if (mode == STGM_READ)
-        ok(ret == STG_E_ACCESSDENIED /* XP */ || ret == S_OK /* 2000 */,
-           "expected STG_E_ACCESSDENIED or S_OK, got 0x%08x\n", ret);
+        ok(ret == STG_E_ACCESSDENIED,
+           "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret);
     else
         ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret);
 
     strcpy(data, "Hello");
     ret = stream->lpVtbl->Write(stream, data, 0, &count);
     if (mode == STGM_READ)
-        ok(ret == STG_E_ACCESSDENIED /* XP */ || ret == S_OK /* 2000 */,
-           "expected STG_E_ACCESSDENIED or S_OK, got 0x%08x\n", ret);
+        ok(ret == STG_E_ACCESSDENIED,
+           "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret);
     else
         ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret);
 
     strcpy(data, "Hello");
     ret = stream->lpVtbl->Write(stream, data, 3, &count);
     if (mode == STGM_READ)
-        ok(ret == STG_E_ACCESSDENIED /* XP */ || ret == S_OK /* 2000 */,
-           "expected STG_E_ACCESSDENIED or S_OK, got 0x%08x\n", ret);
+        ok(ret == STG_E_ACCESSDENIED,
+           "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret);
     else
         ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret);
 
@@ -125,8 +139,8 @@ static void test_IStream_invalid_operations(IStream * stream, DWORD mode)
     ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret);
 
     ret = IStream_Seek(stream, zero, 20, NULL);
-    ok(ret == E_INVALIDARG /* XP */ || ret == S_OK /* 2000 */,
-       "expected E_INVALIDARG or S_OK, got 0x%08x\n", ret);
+    ok(ret == E_INVALIDARG,
+       "expected E_INVALIDARG, got 0x%08x\n", ret);
 
     /* IStream::CopyTo */
 
@@ -178,7 +192,7 @@ static void test_IStream_invalid_operations(IStream * stream, DWORD mode)
     /* IStream::Stat */
 
     ret = IStream_Stat(stream, NULL, 0);
-    ok(ret == STG_E_INVALIDPOINTER /* XP */ || ret == E_NOTIMPL /* 2000 */,
+    ok(ret == STG_E_INVALIDPOINTER,
        "expected STG_E_INVALIDPOINTER or E_NOTIMPL, got 0x%08x\n", ret);
 
     /* IStream::Clone */
@@ -197,6 +211,55 @@ static void test_IStream_invalid_operations(IStream * stream, DWORD mode)
 }
 
 
+static void test_stream_read_write(IStream *stream, DWORD mode)
+{
+    static const LARGE_INTEGER start;
+    HRESULT ret;
+    unsigned char buf[16];
+    DWORD written, count;
+
+    /* IStream_Read/Write from the COBJMACROS is undefined by shlwapi.h */
+
+    written = 0xdeadbeaf;
+    ret = stream->lpVtbl->Write(stream, "\x5e\xa7", 2, &written);
+    if (mode == STGM_WRITE || mode == STGM_READWRITE)
+    {
+        ok(ret == S_OK, "IStream_Write error %#x (access %#x)\n", ret, mode);
+        ok(written == 2, "expected 2, got %u\n", written);
+    }
+    else
+    {
+        ok(ret == STG_E_ACCESSDENIED || broken(ret == S_OK) /* win2000 */, "expected STG_E_ACCESSDENIED, got %#x (access %#x)\n", ret, mode);
+        ok(written == 0xdeadbeaf || broken(written == 2) /* win2000 */, "expected 0xdeadbeaf, got %#x\n", written);
+        written = 0;
+        if (ret == S_OK) return; /* no point in further testing */
+    }
+
+    ret = stream->lpVtbl->Seek(stream, start, STREAM_SEEK_SET, NULL);
+    ok(ret == S_OK, "Seek error %#x\n", ret);
+
+    count = 0xdeadbeaf;
+    ret = stream->lpVtbl->Read(stream, buf, 2, &count);
+    if (written != 0)
+    {
+        ok(ret == S_OK || broken(ret == S_FALSE) /* win2000 */, "IStream_Read error %#x (access %#x, written %u)\n", ret, mode, written);
+        if (ret == S_OK && (mode == STGM_WRITE || mode == STGM_READWRITE))
+        {
+            ok(count == 2, "expected 2, got %u\n", count);
+            ok(buf[0] == 0x5e && buf[1] == 0xa7, "expected 5ea7, got %02x%02x\n", buf[0], buf[1]);
+        }
+        else
+            ok(count == 0, "expected 0, got %u\n", count);
+    }
+    else
+    {
+todo_wine
+        ok(ret == S_FALSE, "expected S_FALSE, got %#x (access %#x, written %u)\n", ret, mode, written);
+        ok(count == 0, "expected 0, got %u\n", count);
+    }
+
+}
+
 static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm)
 {
     IStream * stream;
@@ -226,10 +289,11 @@ static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm)
        "or HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME), got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream);
 
-#if 0 /* This test crashes on WinXP SP2 */
+if (0) /* This test crashes on WinXP SP2 */
+{
     ret = (*pSHCreateStreamOnFileA)(test_file, mode | stgm, NULL);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret);
-#endif
+}
 
     stream = NULL;
     ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CONVERT | stgm, &stream);
@@ -288,6 +352,8 @@ static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm)
 
     if (stream) {
         BOOL delret;
+
+        test_stream_read_write(stream, mode);
         test_IStream_invalid_operations(stream, mode);
 
         refcount = IStream_Release(stream);
@@ -398,6 +464,8 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
 
     if (stream) {
         BOOL delret;
+
+        test_stream_read_write(stream, mode);
         test_IStream_invalid_operations(stream, mode);
 
         refcount = IStream_Release(stream);
@@ -594,6 +662,52 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
 }
 
 
+static void test_SHCreateStreamOnFileEx_CopyTo(void)
+{
+    HRESULT ret;
+    IStream *src, *dst;
+    WCHAR tmpPath[MAX_PATH];
+    WCHAR srcFileName[MAX_PATH];
+    WCHAR dstFileName[MAX_PATH];
+    ULARGE_INTEGER count, read, written;
+    LARGE_INTEGER distance;
+    static const char srcContents[1];
+    static const WCHAR prefix[] = { 'T', 'S', 'T', 0 };
+
+    GetTempPathW(MAX_PATH, tmpPath);
+    GetTempFileNameW(tmpPath, prefix, 0, srcFileName);
+    GetTempFileNameW(tmpPath, prefix, 0, dstFileName);
+
+    ret = pSHCreateStreamOnFileEx(srcFileName, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, FILE_ATTRIBUTE_TEMPORARY, FALSE, NULL, &src);
+    ok(SUCCEEDED(ret), "SHCreateStreamOnFileEx failed with ret=0x%08x\n", ret);
+
+    written.QuadPart = 0;
+    ret = IStream_Write(src, srcContents, sizeof(srcContents), &U(written).LowPart);
+    ok(SUCCEEDED(ret), "ISequentialStream_Write failed with ret=0x%08x\n", ret);
+
+    distance.QuadPart = 0;
+    ret = IStream_Seek(src, distance, STREAM_SEEK_SET, &written);
+    ok(SUCCEEDED(ret), "ISequentialStream_Seek failed with ret=0x%08x\n", ret);
+
+    ret = pSHCreateStreamOnFileEx(dstFileName, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, FILE_ATTRIBUTE_TEMPORARY, FALSE, NULL, &dst);
+    ok(SUCCEEDED(ret), "SHCreateStreamOnFileEx failed with ret=0x%08x\n", ret);
+
+    /* Test using a count larger than the source file, so that the Read operation will fall short */
+    count.QuadPart = 2;
+
+    ret = IStream_CopyTo(src, dst, count, &read, &written);
+    ok(SUCCEEDED(ret), "CopyTo failed with ret=0x%08x\n", ret);
+
+    ok(read.QuadPart == 1, "read does not match size: %d != 1\n", U(read).LowPart);
+    ok(written.QuadPart == 1, "written does not match size: %d != 1\n", U(written).LowPart);
+
+    IStream_Release(dst);
+    IStream_Release(src);
+    DeleteFileW( srcFileName );
+    DeleteFileW( dstFileName );
+}
+
+
 START_TEST(istream)
 {
     static const DWORD stgm_access[] = {
@@ -622,7 +736,7 @@ START_TEST(istream)
 
     int i, j, k;
 
-    hShlwapi = GetModuleHandleA("shlwapi.dll");
+    hShlwapi = LoadLibraryA("shlwapi.dll");
 
     pSHCreateStreamOnFileA = (void*)GetProcAddress(hShlwapi, "SHCreateStreamOnFileA");
     pSHCreateStreamOnFileW = (void*)GetProcAddress(hShlwapi, "SHCreateStreamOnFileW");
@@ -651,4 +765,6 @@ START_TEST(istream)
             }
         }
     }
+
+    if (pSHCreateStreamOnFileEx) test_SHCreateStreamOnFileEx_CopyTo();
 }
index 7b72de3..3e2210b 100755 (executable)
@@ -210,17 +210,17 @@ static void test_GetAcceptLanguagesA(void)
     original[0] = 0;
     res_query = RegQueryValueExA(hroot, acceptlanguage, 0, NULL, (PBYTE)original, &len);
 
-    RegDeleteValue(hroot, acceptlanguage);
+    RegDeleteValueA(hroot, acceptlanguage);
 
     /* Some windows versions use "lang-COUNTRY" as default */
     memset(language, 0, sizeof(language));
     len = GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, language, sizeof(language));
 
     if (len) {
-        lstrcat(language, "-");
+        lstrcatA(language, "-");
         memset(buffer, 0, sizeof(buffer));
         len = GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buffer, sizeof(buffer) - len - 1);
-        lstrcat(language, buffer);
+        lstrcatA(language, buffer);
     }
     else
     {
@@ -340,7 +340,7 @@ static void test_GetAcceptLanguagesA(void)
     }
 
     /* without a value in the registry, a default language is returned */
-    RegDeleteValue(hroot, acceptlanguage);
+    RegDeleteValueA(hroot, acceptlanguage);
 
     len = maxlen;
     memset(buffer, '#', maxlen);
@@ -399,7 +399,7 @@ restore_original:
     }
     else
     {
-        RegDeleteValue(hroot, acceptlanguage);
+        RegDeleteValueA(hroot, acceptlanguage);
     }
     RegCloseKey(hroot);
 }
@@ -1570,14 +1570,14 @@ static void test_SHSetWindowBits(void)
     clsA.cbWndExtra = 0;
     clsA.hInstance = GetModuleHandleA(NULL);
     clsA.hIcon = 0;
-    clsA.hCursor = LoadCursorA(0, IDC_ARROW);
+    clsA.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
     clsA.hbrBackground = NULL;
     clsA.lpszMenuName = NULL;
     clsA.lpszClassName = "Shlwapi test class";
     RegisterClassA(&clsA);
 
     hwnd = CreateWindowA("Shlwapi test class", "Test", WS_VISIBLE, 0, 0, 100, 100,
-                          NULL, NULL, GetModuleHandle(NULL), 0);
+                          NULL, NULL, GetModuleHandleA(NULL), 0);
     ok(IsWindow(hwnd), "failed to create window\n");
 
     /* null window */
@@ -1693,14 +1693,14 @@ if (0)
     flags = FDTF_NOAUTOREADINGORDER | FDTF_SHORTTIME;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff2, sizeof(buff2));
+    ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
 
     flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGTIME;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2));
+    ret = GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
 
@@ -1708,21 +1708,21 @@ if (0)
     flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGTIME | FDTF_SHORTTIME;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2));
+    ret = GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
 
     flags = FDTF_NOAUTOREADINGORDER | FDTF_SHORTDATE;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2));
+    ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
 
     flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGDATE;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
+    ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
 
@@ -1730,7 +1730,7 @@ if (0)
     flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGDATE | FDTF_SHORTDATE;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
+    ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
 
@@ -1738,12 +1738,12 @@ if (0)
     flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGDATE | FDTF_SHORTTIME;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d, length %d\n", ret, lstrlenA(buff)+1);
-    ret = GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3));
+    ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3));
     ok(ret == lstrlenA(buff3)+1, "got %d\n", ret);
     ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0,
        "expected (%s), got (%s) for time part\n",
        buff3, buff + lstrlenA(buff) - lstrlenA(buff3));
-    ret = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
+    ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     buff[lstrlenA(buff2)] = '\0';
     ok(lstrcmpA(buff2, buff) == 0, "expected (%s) got (%s) for date part\n",
@@ -1752,12 +1752,12 @@ if (0)
     flags = FDTF_NOAUTOREADINGORDER | FDTF_LONGDATE | FDTF_LONGTIME;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3));
+    ret = GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3));
     ok(ret == lstrlenA(buff3)+1, "got %d\n", ret);
     ok(lstrcmpA(buff3, buff + lstrlenA(buff) - lstrlenA(buff3)) == 0,
        "expected (%s), got (%s) for time part\n",
        buff3, buff + lstrlenA(buff) - lstrlenA(buff3));
-    ret = GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
+    ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     buff[lstrlenA(buff2)] = '\0';
     ok(lstrcmpA(buff2, buff) == 0, "expected (%s) got (%s) for date part\n",
@@ -1766,10 +1766,10 @@ if (0)
     flags = FDTF_NOAUTOREADINGORDER | FDTF_SHORTDATE | FDTF_SHORTTIME;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2));
+    ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     strcat(buff2, " ");
-    ret = GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3));
+    ret = GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3));
     ok(ret == lstrlenA(buff3)+1, "got %d\n", ret);
     strcat(buff2, buff3);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
@@ -1777,10 +1777,10 @@ if (0)
     flags = FDTF_NOAUTOREADINGORDER | FDTF_SHORTDATE | FDTF_LONGTIME;
     ret = pSHFormatDateTimeA(&filetime, &flags, buff, sizeof(buff));
     ok(ret == lstrlenA(buff)+1, "got %d\n", ret);
-    ret = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2));
+    ret = GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2));
     ok(ret == lstrlenA(buff2)+1, "got %d\n", ret);
     strcat(buff2, " ");
-    ret = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3));
+    ret = GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3));
     ok(ret == lstrlenA(buff3)+1, "got %d\n", ret);
     strcat(buff2, buff3);
     ok(lstrcmpA(buff, buff2) == 0, "expected (%s), got (%s)\n", buff2, buff);
@@ -2278,7 +2278,7 @@ static const IServiceProviderVtbl IServiceProviderImpl_Vtbl =
 
 static void test_IUnknown_QueryServiceExec(void)
 {
-    IServiceProvider *provider = IServiceProviderImpl_Construct();
+    IServiceProvider *provider;
     static const GUID dummy_serviceid = { 0xdeadbeef };
     static const GUID dummy_groupid = { 0xbeefbeef };
     call_trace_t trace_expected;
@@ -2292,6 +2292,8 @@ static void test_IUnknown_QueryServiceExec(void)
         return;
     }
 
+    provider = IServiceProviderImpl_Construct();
+
     /* null source pointer */
     hr = pIUnknown_QueryServiceExec(NULL, &dummy_serviceid, &dummy_groupid, 0, 0, 0, 0);
     ok(hr == E_FAIL, "got 0x%08x\n", hr);
@@ -2390,8 +2392,8 @@ static const IProfferServiceVtbl IProfferServiceImpl_Vtbl =
 
 static void test_IUnknown_ProfferService(void)
 {
-    IServiceProvider *provider = IServiceProviderImpl_Construct();
-    IProfferService *proff = IProfferServiceImpl_Construct();
+    IServiceProvider *provider;
+    IProfferService *proff;
     static const GUID dummy_serviceid = { 0xdeadbeef };
     call_trace_t trace_expected;
     HRESULT hr;
@@ -2405,6 +2407,9 @@ static void test_IUnknown_ProfferService(void)
         return;
     }
 
+    provider = IServiceProviderImpl_Construct();
+    proff = IProfferServiceImpl_Construct();
+
     /* null source pointer */
     hr = pIUnknown_ProfferService(NULL, &dummy_serviceid, 0, 0);
     ok(hr == E_FAIL, "got 0x%08x\n", hr);
@@ -2472,7 +2477,7 @@ static void test_SHCreateWorkerWindowA(void)
     hwnd = pSHCreateWorkerWindowA(0, NULL, 0, 0, 0, 0);
     ok(hwnd != 0, "expected window\n");
 
-    GetClassName(hwnd, classA, 20);
+    GetClassNameA(hwnd, classA, 20);
     ok(lstrcmpA(classA, "WorkerA") == 0, "expected WorkerA class, got %s\n", classA);
 
     ret = GetWindowLongPtrA(hwnd, 0);
@@ -2480,7 +2485,7 @@ static void test_SHCreateWorkerWindowA(void)
 
     /* class info */
     memset(&cliA, 0, sizeof(cliA));
-    res = GetClassInfoA(GetModuleHandle("shlwapi.dll"), "WorkerA", &cliA);
+    res = GetClassInfoA(GetModuleHandleA("shlwapi.dll"), "WorkerA", &cliA);
     ok(res, "failed to get class info\n");
     ok(cliA.style == 0, "got 0x%08x\n", cliA.style);
     ok(cliA.cbClsExtra == 0, "got %d\n", cliA.cbClsExtra);
@@ -2493,7 +2498,7 @@ static void test_SHCreateWorkerWindowA(void)
     hwnd = pSHCreateWorkerWindowA(0, NULL, 0, 0, 0, 0xdeadbeef);
     ok(hwnd != 0, "expected window\n");
 
-    GetClassName(hwnd, classA, 20);
+    GetClassNameA(hwnd, classA, 20);
     ok(lstrcmpA(classA, "WorkerA") == 0, "expected WorkerA class, got %s\n", classA);
 
     ret = GetWindowLongPtrA(hwnd, 0);
index 8ef71c9..d34d01b 100755 (executable)
@@ -39,6 +39,8 @@ static HRESULT (WINAPI *pPathCreateFromUrlA)(LPCSTR, LPSTR, LPDWORD, DWORD);
 static HRESULT (WINAPI *pPathCreateFromUrlW)(LPCWSTR, LPWSTR, LPDWORD, DWORD);
 static HRESULT (WINAPI *pPathCreateFromUrlAlloc)(LPCWSTR, LPWSTR*, DWORD);
 static BOOL    (WINAPI *pPathAppendA)(LPSTR, LPCSTR);
+static BOOL    (WINAPI *pPathUnExpandEnvStringsA)(LPCSTR, LPSTR, UINT);
+static BOOL    (WINAPI *pPathUnExpandEnvStringsW)(LPCWSTR, LPWSTR, UINT);
 
 /* ################ */
 
@@ -288,11 +290,11 @@ static void test_PathCreateFromUrl(void)
             ok(ret == TEST_PATHFROMURL[i].ret, "ret %08x from url %s\n", ret, TEST_PATHFROMURL[i].url);
         if(SUCCEEDED(ret) && TEST_PATHFROMURL[i].path) {
             if(!(TEST_PATHFROMURL[i].todo & 0x2)) {
-                ok(!lstrcmpi(ret_path, TEST_PATHFROMURL[i].path), "got %s expected %s from url %s\n", ret_path, TEST_PATHFROMURL[i].path,  TEST_PATHFROMURL[i].url);
+                ok(!lstrcmpiA(ret_path, TEST_PATHFROMURL[i].path), "got %s expected %s from url %s\n", ret_path, TEST_PATHFROMURL[i].path,  TEST_PATHFROMURL[i].url);
                 ok(len == strlen(ret_path), "ret len %d from url %s\n", len, TEST_PATHFROMURL[i].url);
             } else todo_wine
                 /* Wrong string, don't bother checking the length */
-                ok(!lstrcmpi(ret_path, TEST_PATHFROMURL[i].path), "got %s expected %s from url %s\n", ret_path, TEST_PATHFROMURL[i].path,  TEST_PATHFROMURL[i].url);
+                ok(!lstrcmpiA(ret_path, TEST_PATHFROMURL[i].path), "got %s expected %s from url %s\n", ret_path, TEST_PATHFROMURL[i].path,  TEST_PATHFROMURL[i].url);
         }
 
         if (pPathCreateFromUrlW) {
@@ -587,7 +589,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", NULL);
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\"), "Expected C:\\, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\"), "Expected C:\\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try empty file part */
@@ -595,7 +597,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", "");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\"), "Expected C:\\, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\"), "Expected C:\\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try empty directory and file part */
@@ -603,8 +605,8 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "", "");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "\\") ||
-       broken(!lstrcmp(str, "control")), /* Win95 and some W2K */
+    ok(!lstrcmpA(str, "\\") ||
+       broken(!lstrcmpA(str, "control")), /* Win95 and some W2K */
        "Expected \\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
@@ -613,7 +615,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, NULL, "one\\two\\three");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "one\\two\\three"), "Expected one\\two\\three, got %s\n", str);
+    ok(!lstrcmpA(str, "one\\two\\three"), "Expected one\\two\\three, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try NULL directory and empty file part */
@@ -621,8 +623,8 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, NULL, "");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "\\") ||
-       broken(!lstrcmp(str, "one\\two\\three")), /* Win95 and some W2K */
+    ok(!lstrcmpA(str, "\\") ||
+       broken(!lstrcmpA(str, "one\\two\\three")), /* Win95 and some W2K */
        "Expected \\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef ||
        broken(GetLastError() == ERROR_INVALID_PARAMETER), /* Win95 */
@@ -636,7 +638,7 @@ static void test_PathCombineA(void)
        broken(str != NULL), /* Win95 and some W2K */
        "Expected str == NULL, got %p\n", str);
     ok(lstrlenA(dest) == 0 ||
-       broken(!lstrcmp(dest, "control")), /* Win95 and some W2K */
+       broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
        "Expected 0 length, got %i\n", lstrlenA(dest));
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
@@ -645,7 +647,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:", "one\\two\\three");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try directory with backslash */
@@ -653,7 +655,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", "one\\two\\three");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try directory with backslash and file with prepended backslash */
@@ -661,7 +663,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", "\\one\\two\\three");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try previous test, with backslash appended as well */
@@ -669,7 +671,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", "\\one\\two\\three\\");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try a relative directory */
@@ -681,7 +683,7 @@ static void test_PathCombineA(void)
     if (str)
     {
         ok(str == dest, "Expected str == dest, got %p\n", str);
-        ok(!lstrcmp(str, "one\\two\\three\\"), "Expected one\\two\\three\\, got %s\n", str);
+        ok(!lstrcmpA(str, "one\\two\\three\\"), "Expected one\\two\\three\\, got %s\n", str);
     }
 
     /* try forward slashes */
@@ -689,7 +691,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", "one/two/three\\");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\one/two/three\\"), "Expected one/two/three\\, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\one/two/three\\"), "Expected one/two/three\\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try a really weird directory */
@@ -697,7 +699,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\/\\/", "\\one\\two\\three\\");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try periods */
@@ -705,7 +707,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", "one\\..\\two\\.\\three");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\two\\three"), "Expected C:\\two\\three, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\two\\three"), "Expected C:\\two\\three, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try .. as file */
@@ -714,7 +716,7 @@ static void test_PathCombineA(void)
     lstrcpyA(dest, "control");
     str = PathCombineA(dest, "C:\\", "..");
     ok(str == dest, "Expected str == dest, got %p\n", str);
-    ok(!lstrcmp(str, "C:\\"), "Expected C:\\, got %s\n", str);
+    ok(!lstrcmpA(str, "C:\\"), "Expected C:\\, got %s\n", str);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     memset(too_long, 'a', LONG_LEN);
@@ -726,7 +728,7 @@ static void test_PathCombineA(void)
     str = PathCombineA(dest, "C:\\", too_long);
     ok(str == NULL, "Expected str == NULL, got %p\n", str);
     ok(lstrlenA(dest) == 0 ||
-       broken(!lstrcmp(dest, "control")), /* Win95 and some W2K */
+       broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
        "Expected 0 length, got %i\n", lstrlenA(dest));
     todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
@@ -736,7 +738,7 @@ static void test_PathCombineA(void)
     str = PathCombineA(dest, too_long, "one\\two\\three");
     ok(str == NULL, "Expected str == NULL, got %p\n", str);
     ok(lstrlenA(dest) == 0 ||
-       broken(!lstrcmp(dest, "control")), /* Win95 and some W2K */
+       broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
        "Expected 0 length, got %i\n", lstrlenA(dest));
     todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
@@ -751,7 +753,7 @@ static void test_PathCombineA(void)
     str = PathCombineA(dest, one, two);
     ok(str == NULL, "Expected str == NULL, got %p\n", str);
     ok(lstrlenA(dest) == 0 ||
-       broken(!lstrcmp(dest, "control")), /* Win95 and some W2K */
+       broken(!lstrcmpA(dest, "control")), /* Win95 and some W2K */
        "Expected 0 length, got %i\n", lstrlenA(dest));
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 }
@@ -781,7 +783,7 @@ static void test_PathAddBackslash(void)
     SetLastError(0xdeadbeef);
     str = PathAddBackslashA(path);
     ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
-    ok(!lstrcmp(path, "one\\two\\"), "Expected one\\two\\, got %s\n", path);
+    ok(!lstrcmpA(path, "one\\two\\"), "Expected one\\two\\, got %s\n", path);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try periods */
@@ -789,7 +791,7 @@ static void test_PathAddBackslash(void)
     SetLastError(0xdeadbeef);
     str = PathAddBackslashA(path);
     ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
-    ok(!lstrcmp(path, "one\\..\\two\\"), "Expected one\\..\\two\\, got %s\n", path);
+    ok(!lstrcmpA(path, "one\\..\\two\\"), "Expected one\\..\\two\\, got %s\n", path);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try just a space */
@@ -797,7 +799,7 @@ static void test_PathAddBackslash(void)
     SetLastError(0xdeadbeef);
     str = PathAddBackslashA(path);
     ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
-    ok(!lstrcmp(path, " \\"), "Expected  \\, got %s\n", path);
+    ok(!lstrcmpA(path, " \\"), "Expected  \\, got %s\n", path);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* path already has backslash */
@@ -805,7 +807,7 @@ static void test_PathAddBackslash(void)
     SetLastError(0xdeadbeef);
     str = PathAddBackslashA(path);
     ok(str == (path + lstrlenA(path)), "Expected str to point to end of path, got %p\n", str);
-    ok(!lstrcmp(path, "C:\\one\\"), "Expected C:\\one\\, got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one\\"), "Expected C:\\one\\, got %s\n", path);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     memset(too_long, 'a', LONG_LEN);
@@ -825,21 +827,21 @@ static void test_PathAppendA(void)
     char half[HALF_LEN];
     BOOL res;
 
-    lstrcpy(path, "C:\\one");
+    lstrcpyA(path, "C:\\one");
 
     /* try NULL pszMore */
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, NULL);
     ok(!res, "Expected failure\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C:\\one"), "Expected C:\\one, got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one"), "Expected C:\\one, got %s\n", path);
 
     /* try empty pszMore */
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, "");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C:\\one"), "Expected C:\\one, got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one"), "Expected C:\\one, got %s\n", path);
 
     /* try NULL pszPath */
     SetLastError(0xdeadbeef);
@@ -853,7 +855,7 @@ static void test_PathAppendA(void)
     res = PathAppendA(path, "two\\three");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "two\\three"), "Expected \\two\\three, got %s\n", path);
+    ok(!lstrcmpA(path, "two\\three"), "Expected \\two\\three, got %s\n", path);
 
     /* try empty pszPath and empty pszMore */
     path[0] = '\0';
@@ -861,55 +863,55 @@ static void test_PathAppendA(void)
     res = PathAppendA(path, "");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "\\"), "Expected \\, got %s\n", path);
+    ok(!lstrcmpA(path, "\\"), "Expected \\, got %s\n", path);
 
     /* try legit params */
-    lstrcpy(path, "C:\\one");
+    lstrcpyA(path, "C:\\one");
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, "two\\three");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
 
     /* try pszPath with backslash after it */
-    lstrcpy(path, "C:\\one\\");
+    lstrcpyA(path, "C:\\one\\");
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, "two\\three");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
 
     /* try pszMore with backslash before it */
-    lstrcpy(path, "C:\\one");
+    lstrcpyA(path, "C:\\one");
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, "\\two\\three");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one\\two\\three"), "Expected C:\\one\\two\\three, got %s\n", path);
 
     /* try pszMore with backslash after it */
-    lstrcpy(path, "C:\\one");
+    lstrcpyA(path, "C:\\one");
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, "two\\three\\");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", path);
 
     /* try spaces in pszPath */
-    lstrcpy(path, "C: \\ one ");
+    lstrcpyA(path, "C: \\ one ");
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, "two\\three");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C: \\ one \\two\\three"), "Expected C: \\ one \\two\\three, got %s\n", path);
+    ok(!lstrcmpA(path, "C: \\ one \\two\\three"), "Expected C: \\ one \\two\\three, got %s\n", path);
 
     /* try spaces in pszMore */
-    lstrcpy(path, "C:\\one");
+    lstrcpyA(path, "C:\\one");
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, " two \\ three ");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(path, "C:\\one\\ two \\ three "), "Expected 'C:\\one\\ two \\ three ', got %s\n", path);
+    ok(!lstrcmpA(path, "C:\\one\\ two \\ three "), "Expected 'C:\\one\\ two \\ three ', got %s\n", path);
 
     /* pszPath is too long */
     memset(too_long, 'a', LONG_LEN);
@@ -918,21 +920,21 @@ static void test_PathAppendA(void)
     res = PathAppendA(too_long, "two\\three");
     ok(!res, "Expected failure\n");
     todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(lstrlen(too_long) == 0 ||
-       broken(lstrlen(too_long) == (LONG_LEN - 1)), /* Win95 and some W2K */
-       "Expected length of too_long to be zero, got %i\n", lstrlen(too_long));
+    ok(lstrlenA(too_long) == 0 ||
+       broken(lstrlenA(too_long) == (LONG_LEN - 1)), /* Win95 and some W2K */
+       "Expected length of too_long to be zero, got %i\n", lstrlenA(too_long));
 
     /* pszMore is too long */
-    lstrcpy(path, "C:\\one");
+    lstrcpyA(path, "C:\\one");
     memset(too_long, 'a', LONG_LEN);
     too_long[LONG_LEN - 1] = '\0';
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, too_long);
     ok(!res, "Expected failure\n");
     todo_wine ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(lstrlen(path) == 0 ||
-       broken(!lstrcmp(path, "C:\\one")), /* Win95 and some W2K */
-       "Expected length of path to be zero, got %i\n", lstrlen(path));
+    ok(lstrlenA(path) == 0 ||
+       broken(!lstrcmpA(path, "C:\\one")), /* Win95 and some W2K */
+       "Expected length of path to be zero, got %i\n", lstrlenA(path));
 
     /* both params combined are too long */
     memset(path, 'a', HALF_LEN);
@@ -942,9 +944,9 @@ static void test_PathAppendA(void)
     SetLastError(0xdeadbeef);
     res = PathAppendA(path, half);
     ok(!res, "Expected failure\n");
-    ok(lstrlen(path) == 0 ||
-       broken(lstrlen(path) == (HALF_LEN - 1)), /* Win95 and some W2K */
-       "Expected length of path to be zero, got %i\n", lstrlen(path));
+    ok(lstrlenA(path) == 0 ||
+       broken(lstrlenA(path) == (HALF_LEN - 1)), /* Win95 and some W2K */
+       "Expected length of path to be zero, got %i\n", lstrlenA(path));
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 }
 
@@ -955,23 +957,23 @@ static void test_PathCanonicalizeA(void)
     BOOL res;
 
     /* try a NULL source */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, NULL);
     ok(!res, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, 
        "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
-    ok(dest[0] == 0 || !lstrcmp(dest, "test"),
+    ok(dest[0] == 0 || !lstrcmpA(dest, "test"),
        "Expected either an empty string (Vista) or test, got %s\n", dest);
 
     /* try an empty source */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "\\") ||
-       broken(!lstrcmp(dest, "test")), /* Win95 and some W2K */
+    ok(!lstrcmpA(dest, "\\") ||
+       broken(!lstrcmpA(dest, "test")), /* Win95 and some W2K */
        "Expected \\, got %s\n", dest);
 
     /* try a NULL dest */
@@ -987,82 +989,82 @@ static void test_PathCanonicalizeA(void)
     res = PathCanonicalizeA(dest, "C:\\");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "C:\\"), "Expected C:\\, got %s\n", dest);
+    ok(!lstrcmpA(dest, "C:\\"), "Expected C:\\, got %s\n", dest);
 
     /* try non-empty dest */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "C:\\");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "C:\\"), "Expected C:\\, got %s\n", dest);
+    ok(!lstrcmpA(dest, "C:\\"), "Expected C:\\, got %s\n", dest);
 
     /* try a space for source */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, " ");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, " "), "Expected ' ', got %s\n", dest);
+    ok(!lstrcmpA(dest, " "), "Expected ' ', got %s\n", dest);
 
     /* try a relative path */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "one\\two");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "one\\two"), "Expected one\\two, got %s\n", dest);
+    ok(!lstrcmpA(dest, "one\\two"), "Expected one\\two, got %s\n", dest);
 
     /* try current dir and previous dir */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "C:\\one\\.\\..\\two\\three\\..");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "C:\\two"), "Expected C:\\two, got %s\n", dest);
+    ok(!lstrcmpA(dest, "C:\\two"), "Expected C:\\two, got %s\n", dest);
 
     /* try simple forward slashes */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "C:\\one/two/three\\four/five\\six");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "C:\\one/two/three\\four/five\\six"),
+    ok(!lstrcmpA(dest, "C:\\one/two/three\\four/five\\six"),
        "Expected C:\\one/two/three\\four/five\\six, got %s\n", dest);
 
     /* try simple forward slashes with same dir */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "C:\\one/.\\two");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "C:\\one/.\\two"), "Expected C:\\one/.\\two, got %s\n", dest);
+    ok(!lstrcmpA(dest, "C:\\one/.\\two"), "Expected C:\\one/.\\two, got %s\n", dest);
 
     /* try simple forward slashes with change dir */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "C:\\one/.\\two\\..");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "C:\\one/.") ||
-       !lstrcmp(dest, "C:\\one/"), /* Vista */
+    ok(!lstrcmpA(dest, "C:\\one/.") ||
+       !lstrcmpA(dest, "C:\\one/"), /* Vista */
        "Expected \"C:\\one/.\" or \"C:\\one/\", got \"%s\"\n", dest);
 
     /* try forward slashes with change dirs
      * NOTE: if there is a forward slash in between two backslashes,
      * everything in between the two backslashes is considered on dir
      */
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, "C:\\one/.\\..\\two/three\\..\\four/.five");
     ok(res, "Expected success\n");
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
-    ok(!lstrcmp(dest, "C:\\four/.five"), "Expected C:\\four/.five, got %s\n", dest);
+    ok(!lstrcmpA(dest, "C:\\four/.five"), "Expected C:\\four/.five, got %s\n", dest);
 
     /* try src is too long */
     memset(too_long, 'a', LONG_LEN);
     too_long[LONG_LEN - 1] = '\0';
-    lstrcpy(dest, "test");
+    lstrcpyA(dest, "test");
     SetLastError(0xdeadbeef);
     res = PathCanonicalizeA(dest, too_long);
     ok(!res ||
@@ -1073,7 +1075,7 @@ static void test_PathCanonicalizeA(void)
         ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_FILENAME_EXCED_RANGE /* Vista */,
         "Expected 0xdeadbeef or ERROR_FILENAME_EXCED_RANGE, got %d\n", GetLastError());
     }
-    ok(lstrlen(too_long) == LONG_LEN - 1, "Expected length LONG_LEN - 1, got %i\n", lstrlen(too_long));
+    ok(lstrlenA(too_long) == LONG_LEN - 1, "Expected length LONG_LEN - 1, got %i\n", lstrlenA(too_long));
 }
 
 static void test_PathFindExtensionA(void)
@@ -1093,33 +1095,33 @@ static void test_PathFindExtensionA(void)
     SetLastError(0xdeadbeef);
     ext = PathFindExtensionA(path);
     ok(ext == path, "Expected ext == path, got %p\n", ext);
-    ok(lstrlen(ext) == 0, "Expected length 0, got %i\n", lstrlen(ext));
+    ok(lstrlenA(ext) == 0, "Expected length 0, got %i\n", lstrlenA(ext));
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try a path without an extension */
-    lstrcpy(path, "file");
+    lstrcpyA(path, "file");
     SetLastError(0xdeadbeef);
     ext = PathFindExtensionA(path);
-    ok(ext == path + lstrlen(path), "Expected ext == path, got %p\n", ext);
-    ok(lstrlen(ext) == 0, "Expected length 0, got %i\n", lstrlen(ext));
+    ok(ext == path + lstrlenA(path), "Expected ext == path, got %p\n", ext);
+    ok(lstrlenA(ext) == 0, "Expected length 0, got %i\n", lstrlenA(ext));
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try a path with an extension */
-    lstrcpy(path, "file.txt");
+    lstrcpyA(path, "file.txt");
     SetLastError(0xdeadbeef);
     ext = PathFindExtensionA(path);
-    ok(ext == path + lstrlen("file"),
-       "Expected ext == path + lstrlen(\"file\"), got %p\n", ext);
-    ok(!lstrcmp(ext, ".txt"), "Expected .txt, got %s\n", ext);
+    ok(ext == path + lstrlenA("file"),
+       "Expected ext == path + lstrlenA(\"file\"), got %p\n", ext);
+    ok(!lstrcmpA(ext, ".txt"), "Expected .txt, got %s\n", ext);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try a path with two extensions */
-    lstrcpy(path, "file.txt.doc");
+    lstrcpyA(path, "file.txt.doc");
     SetLastError(0xdeadbeef);
     ext = PathFindExtensionA(path);
-    ok(ext == path + lstrlen("file.txt"),
-       "Expected ext == path + lstrlen(\"file.txt\"), got %p\n", ext);
-    ok(!lstrcmp(ext, ".doc"), "Expected .txt, got %s\n", ext);
+    ok(ext == path + lstrlenA("file.txt"),
+       "Expected ext == path + lstrlenA(\"file.txt\"), got %p\n", ext);
+    ok(!lstrcmpA(ext, ".doc"), "Expected .txt, got %s\n", ext);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try a path longer than MAX_PATH without an extension*/
@@ -1133,12 +1135,12 @@ static void test_PathFindExtensionA(void)
     /* try a path longer than MAX_PATH with an extension*/
     memset(too_long, 'a', LONG_LEN);
     too_long[LONG_LEN - 1] = '\0';
-    lstrcpy(too_long + 300, ".abcde");
-    too_long[lstrlen(too_long)] = 'a';
+    lstrcpyA(too_long + 300, ".abcde");
+    too_long[lstrlenA(too_long)] = 'a';
     SetLastError(0xdeadbeef);
     ext = PathFindExtensionA(too_long);
     ok(ext == too_long + 300, "Expected ext == too_long + 300, got %p\n", ext);
-    ok(lstrlen(ext) == LONG_LEN - 301, "Expected LONG_LEN - 301, got %i\n", lstrlen(ext));
+    ok(lstrlenA(ext) == LONG_LEN - 301, "Expected LONG_LEN - 301, got %i\n", lstrlenA(ext));
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 }
 
@@ -1158,39 +1160,39 @@ static void test_PathBuildRootA(void)
     for (j = 0; j < 26; j++)
     {
         SetLastError(0xdeadbeef);
-        lstrcpy(path, "aaaaaaaaa");
+        lstrcpyA(path, "aaaaaaaaa");
         root = PathBuildRootA(path, j);
         ok(root == path, "Expected root == path, got %p\n", root);
-        ok(!lstrcmp(root, root_expected[j]), "Expected %s, got %s\n", root_expected[j], root);
+        ok(!lstrcmpA(root, root_expected[j]), "Expected %s, got %s\n", root_expected[j], root);
         ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
     }
 
     /* test a negative drive number */
     SetLastError(0xdeadbeef);
-    lstrcpy(path, "aaaaaaaaa");
+    lstrcpyA(path, "aaaaaaaaa");
     root = PathBuildRootA(path, -1);
     ok(root == path, "Expected root == path, got %p\n", root);
-    ok(!lstrcmp(path, "aaaaaaaaa") ||
+    ok(!lstrcmpA(path, "aaaaaaaaa") ||
        lstrlenA(path) == 0, /* Vista */
        "Expected aaaaaaaaa or empty string, got %s\n", path);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* test a drive number greater than 25 */
     SetLastError(0xdeadbeef);
-    lstrcpy(path, "aaaaaaaaa");
+    lstrcpyA(path, "aaaaaaaaa");
     root = PathBuildRootA(path, 26);
     ok(root == path, "Expected root == path, got %p\n", root);
-    ok(!lstrcmp(path, "aaaaaaaaa") ||
+    ok(!lstrcmpA(path, "aaaaaaaaa") ||
        lstrlenA(path) == 0, /* Vista */
        "Expected aaaaaaaaa or empty string, got %s\n", path);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* length of path is less than 4 */
     SetLastError(0xdeadbeef);
-    lstrcpy(path, "aa");
+    lstrcpyA(path, "aa");
     root = PathBuildRootA(path, 0);
     ok(root == path, "Expected root == path, got %p\n", root);
-    ok(!lstrcmp(path, "A:\\"), "Expected A:\\, got %s\n", path);
+    ok(!lstrcmpA(path, "A:\\"), "Expected A:\\, got %s\n", path);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* path is NULL */
@@ -1208,206 +1210,206 @@ static void test_PathCommonPrefixA(void)
 
     /* test NULL path1 */
     SetLastError(0xdeadbeef);
-    lstrcpy(path2, "C:\\");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path2, "C:\\");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(NULL, path2, out);
     ok(count == 0, "Expected 0, got %i\n", count);
     todo_wine
     {
-        ok(!lstrcmp(out, "aaa"), "Expected aaa, got %s\n", out);
+        ok(!lstrcmpA(out, "aaa"), "Expected aaa, got %s\n", out);
     }
-    ok(!lstrcmp(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
+    ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* test NULL path2 */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "C:\\");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "C:\\");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, NULL, out);
     ok(count == 0, "Expected 0, got %i\n", count);
     todo_wine
     {
-        ok(!lstrcmp(out, "aaa"), "Expected aaa, got %s\n", out);
+        ok(!lstrcmpA(out, "aaa"), "Expected aaa, got %s\n", out);
     }
-    ok(!lstrcmp(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
+    ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* test empty path1 */
     SetLastError(0xdeadbeef);
     path1[0] = '\0';
-    lstrcpy(path2, "C:\\");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path2, "C:\\");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 0, "Expected 0, got %i\n", count);
-    ok(lstrlen(out) == 0, "Expected 0 length out, got %i\n", lstrlen(out));
-    ok(lstrlen(path1) == 0, "Expected 0 length path1, got %i\n", lstrlen(path1));
-    ok(!lstrcmp(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
+    ok(lstrlenA(out) == 0, "Expected 0 length out, got %i\n", lstrlenA(out));
+    ok(lstrlenA(path1) == 0, "Expected 0 length path1, got %i\n", lstrlenA(path1));
+    ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* test empty path1 */
     SetLastError(0xdeadbeef);
     path2[0] = '\0';
-    lstrcpy(path1, "C:\\");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "C:\\");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 0, "Expected 0, got %i\n", count);
-    ok(lstrlen(out) == 0, "Expected 0 length out, got %i\n", lstrlen(out));
-    ok(lstrlen(path2) == 0, "Expected 0 length path2, got %i\n", lstrlen(path2));
-    ok(!lstrcmp(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
+    ok(lstrlenA(out) == 0, "Expected 0 length out, got %i\n", lstrlenA(out));
+    ok(lstrlenA(path2) == 0, "Expected 0 length path2, got %i\n", lstrlenA(path2));
+    ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* paths are legit, out is NULL */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "C:\\");
-    lstrcpy(path2, "C:\\");
+    lstrcpyA(path1, "C:\\");
+    lstrcpyA(path2, "C:\\");
     count = PathCommonPrefixA(path1, path2, NULL);
     ok(count == 3, "Expected 3, got %i\n", count);
-    ok(!lstrcmp(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
-    ok(!lstrcmp(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
+    ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
+    ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* all parameters legit */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "C:\\");
-    lstrcpy(path2, "C:\\");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "C:\\");
+    lstrcpyA(path2, "C:\\");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 3, "Expected 3, got %i\n", count);
-    ok(!lstrcmp(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
-    ok(!lstrcmp(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
-    ok(!lstrcmp(out, "C:\\"), "Expected C:\\, got %s\n", out);
+    ok(!lstrcmpA(path1, "C:\\"), "Expected C:\\, got %s\n", path1);
+    ok(!lstrcmpA(path2, "C:\\"), "Expected C:\\, got %s\n", path2);
+    ok(!lstrcmpA(out, "C:\\"), "Expected C:\\, got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* path1 and path2 not the same, but common prefix */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "C:\\one\\two");
-    lstrcpy(path2, "C:\\one\\three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "C:\\one\\two");
+    lstrcpyA(path2, "C:\\one\\three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 6, "Expected 6, got %i\n", count);
-    ok(!lstrcmp(path1, "C:\\one\\two"), "Expected C:\\one\\two, got %s\n", path1);
-    ok(!lstrcmp(path2, "C:\\one\\three"), "Expected C:\\one\\three, got %s\n", path2);
-    ok(!lstrcmp(out, "C:\\one"), "Expected C:\\one, got %s\n", out);
+    ok(!lstrcmpA(path1, "C:\\one\\two"), "Expected C:\\one\\two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "C:\\one\\three"), "Expected C:\\one\\three, got %s\n", path2);
+    ok(!lstrcmpA(out, "C:\\one"), "Expected C:\\one, got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try . prefix */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\.two");
-    lstrcpy(path2, "one\\.three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\.two");
+    lstrcpyA(path2, "one\\.three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 3, "Expected 3, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\.two"), "Expected one\\.two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\.three"), "Expected one\\.three, got %s\n", path2);
-    ok(!lstrcmp(out, "one"), "Expected one, got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\.two"), "Expected one\\.two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\.three"), "Expected one\\.three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one"), "Expected one, got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try .. prefix */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\..two");
-    lstrcpy(path2, "one\\..three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\..two");
+    lstrcpyA(path2, "one\\..three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 3, "Expected 3, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\..two"), "Expected one\\..two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\..three"), "Expected one\\..three, got %s\n", path2);
-    ok(!lstrcmp(out, "one"), "Expected one, got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\..two"), "Expected one\\..two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\..three"), "Expected one\\..three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one"), "Expected one, got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try ... prefix */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\...two");
-    lstrcpy(path2, "one\\...three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\...two");
+    lstrcpyA(path2, "one\\...three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 3, "Expected 3, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\...two"), "Expected one\\...two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\...three"), "Expected one\\...three, got %s\n", path2);
-    ok(!lstrcmp(out, "one"), "Expected one, got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\...two"), "Expected one\\...two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\...three"), "Expected one\\...three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one"), "Expected one, got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try .\ prefix */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\.\\two");
-    lstrcpy(path2, "one\\.\\three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\.\\two");
+    lstrcpyA(path2, "one\\.\\three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 5, "Expected 5, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\.\\two"), "Expected one\\.\\two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\.\\three"), "Expected one\\.\\three, got %s\n", path2);
-    ok(!lstrcmp(out, "one\\."), "Expected one\\., got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\.\\two"), "Expected one\\.\\two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\.\\three"), "Expected one\\.\\three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one\\."), "Expected one\\., got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try ..\ prefix */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\..\\two");
-    lstrcpy(path2, "one\\..\\three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\..\\two");
+    lstrcpyA(path2, "one\\..\\three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 6, "Expected 6, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\..\\two"), "Expected one\\..\\two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\..\\three"), "Expected one\\..\\three, got %s\n", path2);
-    ok(!lstrcmp(out, "one\\.."), "Expected one\\.., got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\..\\two"), "Expected one\\..\\two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\..\\three"), "Expected one\\..\\three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one\\.."), "Expected one\\.., got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try ...\\ prefix */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\...\\two");
-    lstrcpy(path2, "one\\...\\three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\...\\two");
+    lstrcpyA(path2, "one\\...\\three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 7, "Expected 7, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\...\\two"), "Expected one\\...\\two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\...\\three"), "Expected one\\...\\three, got %s\n", path2);
-    ok(!lstrcmp(out, "one\\..."), "Expected one\\..., got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\...\\two"), "Expected one\\...\\two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\...\\three"), "Expected one\\...\\three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one\\..."), "Expected one\\..., got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try prefix that is not an msdn labeled prefix type */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "same");
-    lstrcpy(path2, "same");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "same");
+    lstrcpyA(path2, "same");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 4, "Expected 4, got %i\n", count);
-    ok(!lstrcmp(path1, "same"), "Expected same, got %s\n", path1);
-    ok(!lstrcmp(path2, "same"), "Expected same, got %s\n", path2);
-    ok(!lstrcmp(out, "same"), "Expected same, got %s\n", out);
+    ok(!lstrcmpA(path1, "same"), "Expected same, got %s\n", path1);
+    ok(!lstrcmpA(path2, "same"), "Expected same, got %s\n", path2);
+    ok(!lstrcmpA(out, "same"), "Expected same, got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try . after directory */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\mid.\\two");
-    lstrcpy(path2, "one\\mid.\\three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\mid.\\two");
+    lstrcpyA(path2, "one\\mid.\\three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 8, "Expected 8, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\mid.\\two"), "Expected one\\mid.\\two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\mid.\\three"), "Expected one\\mid.\\three, got %s\n", path2);
-    ok(!lstrcmp(out, "one\\mid."), "Expected one\\mid., got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\mid.\\two"), "Expected one\\mid.\\two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\mid.\\three"), "Expected one\\mid.\\three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one\\mid."), "Expected one\\mid., got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try . in the middle of a directory */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\mid.end\\two");
-    lstrcpy(path2, "one\\mid.end\\three");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\mid.end\\two");
+    lstrcpyA(path2, "one\\mid.end\\three");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 11, "Expected 11, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\mid.end\\two"), "Expected one\\mid.end\\two, got %s\n", path1);
-    ok(!lstrcmp(path2, "one\\mid.end\\three"), "Expected one\\mid.end\\three, got %s\n", path2);
-    ok(!lstrcmp(out, "one\\mid.end"), "Expected one\\mid.end, got %s\n", out);
+    ok(!lstrcmpA(path1, "one\\mid.end\\two"), "Expected one\\mid.end\\two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "one\\mid.end\\three"), "Expected one\\mid.end\\three, got %s\n", path2);
+    ok(!lstrcmpA(out, "one\\mid.end"), "Expected one\\mid.end, got %s\n", out);
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 
     /* try comparing a .. with the expanded path */
     SetLastError(0xdeadbeef);
-    lstrcpy(path1, "one\\..\\two");
-    lstrcpy(path2, "two");
-    lstrcpy(out, "aaa");
+    lstrcpyA(path1, "one\\..\\two");
+    lstrcpyA(path2, "two");
+    lstrcpyA(out, "aaa");
     count = PathCommonPrefixA(path1, path2, out);
     ok(count == 0, "Expected 0, got %i\n", count);
-    ok(!lstrcmp(path1, "one\\..\\two"), "Expected one\\..\\two, got %s\n", path1);
-    ok(!lstrcmp(path2, "two"), "Expected two, got %s\n", path2);
-    ok(lstrlen(out) == 0, "Expected 0 length out, got %i\n", lstrlen(out));
+    ok(!lstrcmpA(path1, "one\\..\\two"), "Expected one\\..\\two, got %s\n", path1);
+    ok(!lstrcmpA(path2, "two"), "Expected two, got %s\n", path2);
+    ok(lstrlenA(out) == 0, "Expected 0 length out, got %i\n", lstrlenA(out));
     ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
 }
 
@@ -1457,7 +1459,136 @@ static void test_PathGetDriveNumber(void)
     ok(ret == -1, "got %d\n", ret);
 }
 
-/* ################ */
+static void test_PathUnExpandEnvStrings(void)
+{
+    static const WCHAR sysrootW[] = {'%','S','y','s','t','e','m','R','o','o','t','%',0};
+    static const WCHAR sysdriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%',0};
+    static const WCHAR nonpathW[] = {'p','a','t','h',0};
+    static const char sysrootA[] = "%SystemRoot%";
+    static const char sysdriveA[] = "%SystemDrive%";
+    WCHAR pathW[MAX_PATH], buffW[MAX_PATH], sysdrvW[3];
+    char path[MAX_PATH], buff[MAX_PATH], sysdrvA[3], envvarA[10];
+    BOOL ret;
+    UINT len;
+
+    if (!pPathUnExpandEnvStringsA || !pPathUnExpandEnvStringsW)
+    {
+        win_skip("PathUnExpandEnvStrings not available\n");
+        return;
+    }
+
+    /* something that can't be represented with env var */
+    strcpy(path, "somepath_name");
+    strcpy(buff, "xx");
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
+    ok(buff[0] == 'x', "wrong return string %s\n", buff);
+
+    len = GetSystemDirectoryA(path, MAX_PATH);
+    ok(len > 0, "failed to get sysdir\n");
+
+    sysdrvA[0] = path[0];
+    strcpy(&sysdrvA[1], ":");
+
+    /* buffer size is not enough */
+    strcpy(buff, "xx");
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsA(path, buff, 5);
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d\n", ret);
+    ok(buff[0] == 'x', "wrong return string %s\n", buff);
+
+    /* buffer size is enough to hold variable name only */
+    strcpy(buff, "xx");
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsA(path, buff, sizeof(sysrootA));
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
+    ok(buff[0] == 'x', "wrong return string %s\n", buff);
+
+    /* enough size */
+    buff[0] = 0;
+    ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
+    ok(ret, "got %d\n", ret);
+    ok(!strncmp(buff, sysrootA, sizeof(sysrootA)-1), "wrong return string %s\n", buff);
+
+    /* expanded value occurs multiple times */
+    /* for drive C: it unexpands it like 'C:C:' -> '%SystemDrive%C:' */
+    buff[0] = 0;
+    strcpy(path, sysdrvA);
+    strcat(path, sysdrvA);
+    ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
+    ok(ret, "got %d\n", ret);
+    /* expected string */
+    strcpy(path, sysdriveA);
+    strcat(path, sysdrvA);
+    ok(!strcmp(buff, path), "wrong unexpanded string %s, expected %s\n", buff, path);
+
+    /* now with altered variable */
+    ret = GetEnvironmentVariableA("SystemDrive", envvarA, sizeof(envvarA));
+    ok(ret, "got %d\n", ret);
+
+    ret = SetEnvironmentVariableA("SystemDrive", "WW");
+    ok(ret, "got %d\n", ret);
+
+    /* variables are not cached */
+    strcpy(path, sysdrvA);
+    strcat(path, sysdrvA);
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsA(path, buff, sizeof(buff));
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
+
+    ret = SetEnvironmentVariableA("SystemDrive", envvarA);
+    ok(ret, "got %d\n", ret);
+
+    /* PathUnExpandEnvStringsW */
+
+    /* something that can't be represented with env var */
+    lstrcpyW(pathW, nonpathW);
+    buffW[0] = 'x'; buffW[1] = 0;
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buffW)/sizeof(WCHAR));
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
+    ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
+
+    len = GetSystemDirectoryW(pathW, MAX_PATH);
+    ok(len > 0, "failed to get sysdir\n");
+
+    sysdrvW[0] = pathW[0];
+    sysdrvW[1] = ':';
+    sysdrvW[2] = 0;
+
+    /* buffer size is not enough */
+    buffW[0] = 'x'; buffW[1] = 0;
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsW(pathW, buffW, 5);
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
+    ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
+
+    /* buffer size is enough to hold variable name only */
+    buffW[0] = 'x'; buffW[1] = 0;
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(sysrootW)/sizeof(WCHAR));
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
+    ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
+
+    /* enough size */
+    buffW[0] = 0;
+    ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buffW)/sizeof(WCHAR));
+    ok(ret, "got %d\n", ret);
+    ok(!memcmp(buffW, sysrootW, sizeof(sysrootW) - sizeof(WCHAR)), "wrong return string %s\n", wine_dbgstr_w(buffW));
+
+    /* expanded value occurs multiple times */
+    /* for drive C: it unexpands it like 'C:C:' -> '%SystemDrive%C:' */
+    buffW[0] = 0;
+    lstrcpyW(pathW, sysdrvW);
+    lstrcatW(pathW, sysdrvW);
+    ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buff)/sizeof(WCHAR));
+    ok(ret, "got %d\n", ret);
+    /* expected string */
+    lstrcpyW(pathW, sysdriveW);
+    lstrcatW(pathW, sysdrvW);
+    ok(!lstrcmpW(buffW, pathW), "wrong unexpanded string %s, expected %s\n", wine_dbgstr_w(buffW), wine_dbgstr_w(pathW));
+}
 
 START_TEST(path)
 {
@@ -1476,6 +1607,8 @@ START_TEST(path)
     pPathIsValidCharA = (void*)GetProcAddress(hShlwapi, (LPSTR)455);
     pPathIsValidCharW = (void*)GetProcAddress(hShlwapi, (LPSTR)456);
     pPathAppendA = (void*)GetProcAddress(hShlwapi, "PathAppendA");
+    pPathUnExpandEnvStringsA = (void*)GetProcAddress(hShlwapi, "PathUnExpandEnvStringsA");
+    pPathUnExpandEnvStringsW = (void*)GetProcAddress(hShlwapi, "PathUnExpandEnvStringsW");
 
     test_PathSearchAndQualify();
     test_PathCreateFromUrl();
@@ -1497,4 +1630,5 @@ START_TEST(path)
     test_PathCommonPrefixA();
     test_PathUnquoteSpaces();
     test_PathGetDriveNumber();
+    test_PathUnExpandEnvStrings();
 }
index c6b55fe..80d161e 100755 (executable)
@@ -43,8 +43,8 @@ static DWORD (WINAPI *pSHRegGetPathA)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
 static LSTATUS (WINAPI *pSHRegGetValueA)(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD);
 static LSTATUS (WINAPI *pSHRegCreateUSKeyW)(LPCWSTR,REGSAM,HUSKEY,PHUSKEY,DWORD);
 
-static char sTestpath1[] = "%LONGSYSTEMVAR%\\subdir1";
-static char sTestpath2[] = "%FOO%\\subdir1";
+static const char sTestpath1[] = "%LONGSYSTEMVAR%\\subdir1";
+static const char sTestpath2[] = "%FOO%\\subdir1";
 
 static const char * sEnvvar1 = "bar";
 static const char * sEnvvar2 = "ImARatherLongButIndeedNeededString";
@@ -412,15 +412,15 @@ static void test_SHDeleteKey(void)
 
     if (!RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY, &hKeyTest))
     {
-        if (!RegCreateKey(hKeyTest, "ODBC", &hKeyS))
+        if (!RegCreateKeyA(hKeyTest, "ODBC", &hKeyS))
         {
             HKEY hKeyO;
 
-            if (!RegCreateKey(hKeyS, "ODBC.INI", &hKeyO))
+            if (!RegCreateKeyA(hKeyS, "ODBC.INI", &hKeyO))
             {
                 RegCloseKey (hKeyO);
 
-                if (!RegCreateKey(hKeyS, "ODBCINST.INI", &hKeyO))
+                if (!RegCreateKeyA(hKeyS, "ODBCINST.INI", &hKeyO))
                 {
                     RegCloseKey (hKeyO);
                     sysfail = 0;
index 619f118..45c8bba 100755 (executable)
@@ -69,7 +69,7 @@ static LPWSTR  (WINAPI *pStrStrNW)(LPCWSTR,LPCWSTR,UINT);
 static LPWSTR  (WINAPI *pStrStrNIW)(LPCWSTR,LPCWSTR,UINT);
 static INT     (WINAPIV *pwnsprintfA)(LPSTR,INT,LPCSTR, ...);
 static INT     (WINAPIV *pwnsprintfW)(LPWSTR,INT,LPCWSTR, ...);
-static LPWSTR  (WINAPI *pStrChrNW)(LPWSTR,WCHAR,UINT);
+static LPWSTR  (WINAPI *pStrChrNW)(LPCWSTR,WCHAR,UINT);
 static BOOL    (WINAPI *pStrToInt64ExA)(LPCSTR,DWORD,LONGLONG*);
 static BOOL    (WINAPI *pStrToInt64ExW)(LPCWSTR,DWORD,LONGLONG*);
 
@@ -438,7 +438,7 @@ static void test_StrCpyW(void)
 
 static void test_StrChrNW(void)
 {
-    static WCHAR string[] = {'T','e','s','t','i','n','g',' ','S','t','r','i','n','g',0};
+    static const WCHAR string[] = {'T','e','s','t','i','n','g',' ','S','t','r','i','n','g',0};
     LPWSTR p;
 
     if (!pStrChrNW)
@@ -1074,7 +1074,7 @@ if (0)
     {
         memset(buf, 0xbf, sizeof(buf));
         strret.uType = STRRET_CSTR;
-        StrCpyN(U(strret).cStr, str1, MAX_PATH);
+        StrCpyNA(U(strret).cStr, str1, MAX_PATH);
         expect_eq2(pStrRetToBufA(&strret, NULL, buf, 10), S_OK, HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) /* Vista */, HRESULT, "%x");
         expect_eq(buf[9], 0, CHAR, "%x");
         expect_eq(buf[10], (CHAR)0xbf, CHAR, "%x");
@@ -1489,12 +1489,12 @@ static void test_StrStrNIW(void)
 START_TEST(string)
 {
   HMODULE hShlwapi;
-  TCHAR thousandDelim[8];
-  TCHAR decimalDelim[8];
+  CHAR thousandDelim[8];
+  CHAR decimalDelim[8];
   CoInitialize(0);
 
-  GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousandDelim, 8);
-  GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimalDelim, 8);
+  GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousandDelim, 8);
+  GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimalDelim, 8);
 
   hShlwapi = GetModuleHandleA("shlwapi");
   pChrCmpIA = (void *)GetProcAddress(hShlwapi, "ChrCmpIA");
index abdf880..f48fa7f 100644 (file)
@@ -302,7 +302,9 @@ static const TEST_URL_ESCAPE TEST_ESCAPE[] = {
     {"ftp://fo/o@bar.baz/fo#o\\bar", 0, 0, S_OK, "ftp://fo/o@bar.baz/fo#o\\bar"},
     {"ftp://localhost/o@bar.baz/fo#o\\bar", 0, 0, S_OK, "ftp://localhost/o@bar.baz/fo#o\\bar"},
     {"ftp:///fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:///fo/o@bar.baz/foo/bar"},
-    {"ftp:////fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:////fo/o@bar.baz/foo/bar"}
+    {"ftp:////fo/o@bar.baz/foo/bar", 0, 0, S_OK, "ftp:////fo/o@bar.baz/foo/bar"},
+
+    {"ftp\x1f\1end/", 0, 0, S_OK, "ftp%1F%01end/"}
 };
 
 /* ################ */
@@ -332,6 +334,8 @@ static const TEST_URL_COMBINE TEST_COMBINE[] = {
     {"http://www.winehq.org/test12", "#", 0, S_OK, "http://www.winehq.org/test12#"},
     {"http://www.winehq.org/test13#aaa", "#bbb", 0, S_OK, "http://www.winehq.org/test13#bbb"},
     {"http://www.winehq.org/test14#aaa/bbb#ccc", "#", 0, S_OK, "http://www.winehq.org/test14#"},
+    {"http://www.winehq.org/tests/?query=x/y/z", "tests15", 0, S_OK, "http://www.winehq.org/tests/tests15"},
+    {"http://www.winehq.org/tests/?query=x/y/z#example", "tests16", 0, S_OK, "http://www.winehq.org/tests/tests16"},
     {"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK, "file:///C:/dir/test.txt"},
     {"file:///C:\\dir\\file.txt#hash\\hash", "test.txt", 0, S_OK, "file:///C:/dir/file.txt#hash/test.txt"},
     {"file:///C:\\dir\\file.html#hash\\hash", "test.html", 0, S_OK, "file:///C:/dir/test.html"},
@@ -782,34 +786,6 @@ static void test_UrlGetPart(void)
 }
 
 /* ########################### */
-
-static void test_url_escape(const char *szUrl, DWORD dwFlags, HRESULT dwExpectReturn, const char *szExpectUrl)
-{
-    CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
-    DWORD dwEscaped;
-    WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
-    WCHAR *urlW, *expected_urlW;
-    dwEscaped=INTERNET_MAX_URL_LENGTH;
-
-    ok(pUrlEscapeA(szUrl, szReturnUrl, &dwEscaped, dwFlags) == dwExpectReturn,
-        "UrlEscapeA didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl);
-    ok(strcmp(szReturnUrl,szExpectUrl)==0, "Expected \"%s\", but got \"%s\" from \"%s\"\n", szExpectUrl, szReturnUrl, szUrl);
-
-    if (pUrlEscapeW) {
-        dwEscaped = INTERNET_MAX_URL_LENGTH;
-        urlW = GetWideString(szUrl);
-        expected_urlW = GetWideString(szExpectUrl);
-        ok(pUrlEscapeW(urlW, ret_urlW, &dwEscaped, dwFlags) == dwExpectReturn,
-            "UrlEscapeW didn't return 0x%08x from \"%s\"\n", dwExpectReturn, szUrl);
-        WideCharToMultiByte(CP_ACP,0,ret_urlW,-1,szReturnUrl,INTERNET_MAX_URL_LENGTH,0,0);
-        ok(lstrcmpW(ret_urlW, expected_urlW)==0,
-            "Expected \"%s\", but got \"%s\" from \"%s\" flags %08x\n",
-            szExpectUrl, szReturnUrl, szUrl, dwFlags);
-        FreeWideString(urlW);
-        FreeWideString(expected_urlW);
-    }
-}
-
 static void test_url_canonicalize(int index, const char *szUrl, DWORD dwFlags, HRESULT dwExpectReturn, HRESULT dwExpectReturnAlt, const char *szExpectUrl, BOOL todo)
 {
     CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
@@ -853,18 +829,15 @@ static void test_url_canonicalize(int index, const char *szUrl, DWORD dwFlags, H
 }
 
 
-static void test_UrlEscape(void)
+static void test_UrlEscapeA(void)
 {
-    static const WCHAR out[] = { 'f','o','o','%','2','0','b','a','r',0 };
-
     DWORD size = 0;
     HRESULT ret;
     unsigned int i;
     char empty_string[] = "";
-    WCHAR overwrite[] = { 'f','o','o',' ','b','a','r',0,0,0 };
 
     if (!pUrlEscapeA) {
-        win_skip("UrlEscapeA noz found\n");
+        win_skip("UrlEscapeA not found\n");
         return;
     }
 
@@ -894,26 +867,68 @@ static void test_UrlEscape(void)
     ok(size == 34, "got %d, expected %d\n", size, 34);
     ok(empty_string[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string[0]);
 
-    if(pUrlEscapeW) {
-        WCHAR wc;
-
-        size = sizeof(overwrite)/sizeof(WCHAR);
-        ret = pUrlEscapeW(overwrite, overwrite, &size, URL_ESCAPE_SPACES_ONLY);
-        ok(ret == S_OK, "got %x, expected S_OK\n", ret);
-        ok(size == 9, "got %d, expected 9\n", size);
-        ok(!lstrcmpW(overwrite, out), "got %s, expected %s\n", wine_dbgstr_w(overwrite), wine_dbgstr_w(out));
-
-        size = 1;
-        wc = 127;
-        ret = pUrlEscapeW(overwrite, &wc, &size, URL_ESCAPE_SPACES_ONLY);
-        ok(ret == E_POINTER, "got %x, expected %x\n", ret, E_POINTER);
-        ok(size == 10, "got %d, expected 10\n", size);
-        ok(wc == 127, "String has changed, wc = %d\n", wc);
+    for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
+        CHAR ret_url[INTERNET_MAX_URL_LENGTH];
+
+        size = INTERNET_MAX_URL_LENGTH;
+        ret = pUrlEscapeA(TEST_ESCAPE[i].url, ret_url, &size, TEST_ESCAPE[i].flags);
+        ok(ret == TEST_ESCAPE[i].expectret, "UrlEscapeA returned 0x%08x instead of 0x%08x for \"%s\"\n",
+            ret, TEST_ESCAPE[i].expectret, TEST_ESCAPE[i].url);
+        ok(!strcmp(ret_url, TEST_ESCAPE[i].expecturl), "Expected \"%s\", but got \"%s\" for \"%s\"\n",
+            TEST_ESCAPE[i].expecturl, ret_url, TEST_ESCAPE[i].url);
     }
+}
 
-    for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
-        test_url_escape(TEST_ESCAPE[i].url, TEST_ESCAPE[i].flags,
-                              TEST_ESCAPE[i].expectret, TEST_ESCAPE[i].expecturl);
+static void test_UrlEscapeW(void)
+{
+    static const WCHAR naW[] = {'f','t','p',31,255,250,0x2122,'e','n','d','/',0};
+    static const WCHAR naescapedW[] = {'f','t','p','%','1','F','%','F','F','%','F','A',0x2122,'e','n','d','/',0};
+    static const WCHAR out[] = {'f','o','o','%','2','0','b','a','r',0};
+    WCHAR overwrite[] = {'f','o','o',' ','b','a','r',0,0,0};
+    WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
+    DWORD size = 0;
+    HRESULT ret;
+    WCHAR wc;
+    int i;
+
+    if (!pUrlEscapeW) {
+        win_skip("UrlEscapeW not found\n");
+        return;
+    }
+
+    size = sizeof(overwrite)/sizeof(WCHAR);
+    ret = pUrlEscapeW(overwrite, overwrite, &size, URL_ESCAPE_SPACES_ONLY);
+    ok(ret == S_OK, "got %x, expected S_OK\n", ret);
+    ok(size == 9, "got %d, expected 9\n", size);
+    ok(!lstrcmpW(overwrite, out), "got %s, expected %s\n", wine_dbgstr_w(overwrite), wine_dbgstr_w(out));
+
+    size = 1;
+    wc = 127;
+    ret = pUrlEscapeW(overwrite, &wc, &size, URL_ESCAPE_SPACES_ONLY);
+    ok(ret == E_POINTER, "got %x, expected %x\n", ret, E_POINTER);
+    ok(size == 10, "got %d, expected 10\n", size);
+    ok(wc == 127, "String has changed, wc = %d\n", wc);
+
+    /* non-ASCII range */
+    size = sizeof(ret_urlW)/sizeof(WCHAR);
+    ret = pUrlEscapeW(naW, ret_urlW, &size, 0);
+    ok(ret == S_OK, "got %x, expected S_OK\n", ret);
+    ok(!lstrcmpW(naescapedW, ret_urlW), "got %s, expected %s\n", wine_dbgstr_w(ret_urlW), wine_dbgstr_w(naescapedW));
+
+    for (i = 0; i < sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
+
+        WCHAR *urlW, *expected_urlW;
+
+        size = INTERNET_MAX_URL_LENGTH;
+        urlW = GetWideString(TEST_ESCAPE[i].url);
+        expected_urlW = GetWideString(TEST_ESCAPE[i].expecturl);
+        ret = pUrlEscapeW(urlW, ret_urlW, &size, TEST_ESCAPE[i].flags);
+        ok(ret == TEST_ESCAPE[i].expectret, "UrlEscapeW returned 0x%08x instead of 0x%08x for %s\n",
+           ret, TEST_ESCAPE[i].expectret, wine_dbgstr_w(urlW));
+        ok(!lstrcmpW(ret_urlW, expected_urlW), "Expected %s, but got %s for %s flags %08x\n",
+            wine_dbgstr_w(expected_urlW), wine_dbgstr_w(ret_urlW), wine_dbgstr_w(urlW), TEST_ESCAPE[i].flags);
+        FreeWideString(urlW);
+        FreeWideString(expected_urlW);
     }
 }
 
@@ -1085,19 +1100,20 @@ static void test_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFla
     HRESULT hr;
     CHAR szReturnUrl[INTERNET_MAX_URL_LENGTH];
     WCHAR wszReturnUrl[INTERNET_MAX_URL_LENGTH];
-    LPWSTR wszUrl1 = GetWideString(szUrl1);
-    LPWSTR wszUrl2 = GetWideString(szUrl2);
-    LPWSTR wszExpectUrl = GetWideString(szExpectUrl);
-    LPWSTR wszConvertedUrl;
+    LPWSTR wszUrl1, wszUrl2, wszExpectUrl, wszConvertedUrl;
 
     DWORD dwSize;
-    DWORD dwExpectLen = lstrlen(szExpectUrl);
+    DWORD dwExpectLen = lstrlenA(szExpectUrl);
 
     if (!pUrlCombineA) {
         win_skip("UrlCombineA not found\n");
         return;
     }
 
+    wszUrl1 = GetWideString(szUrl1);
+    wszUrl2 = GetWideString(szUrl2);
+    wszExpectUrl = GetWideString(szExpectUrl);
+
     hr = pUrlCombineA(szUrl1, szUrl2, NULL, NULL, dwFlags);
     ok(hr == E_INVALIDARG, "UrlCombineA returned 0x%08x, expected 0x%08x\n", hr, E_INVALIDARG);
 
@@ -1174,7 +1190,7 @@ static void test_UrlCreateFromPath(void)
         len = INTERNET_MAX_URL_LENGTH;
         ret = pUrlCreateFromPathA(TEST_URLFROMPATH[i].path, ret_url, &len, 0);
         ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path %s\n", ret, TEST_URLFROMPATH[i].path);
-        ok(!lstrcmpi(ret_url, TEST_URLFROMPATH[i].url), "url %s from path %s\n", ret_url, TEST_URLFROMPATH[i].path);
+        ok(!lstrcmpiA(ret_url, TEST_URLFROMPATH[i].url), "url %s from path %s\n", ret_url, TEST_URLFROMPATH[i].path);
         ok(len == strlen(ret_url), "ret len %d from path %s\n", len, TEST_URLFROMPATH[i].path);
 
         if (pUrlCreateFromPathW) {
@@ -1550,7 +1566,8 @@ START_TEST(url)
   test_UrlGetPart();
   test_UrlCanonicalizeA();
   test_UrlCanonicalizeW();
-  test_UrlEscape();
+  test_UrlEscapeA();
+  test_UrlEscapeW();
   test_UrlCombine();
   test_UrlCreateFromPath();
   test_UrlIs();