ReactOS 0.4.17-dev-470-gf9e3448
shellpath.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "shlguid.h"
#include "shlobj.h"
#include "shlwapi.h"
#include "knownfolders.h"
#include "shellapi.h"
#include "wine/test.h"
#include "initguid.h"
Include dependency graph for shellpath.c:

Go to the source code of this file.

Classes

struct  shellExpectedValues
 
struct  knownFolderDef
 

Macros

#define COBJMACROS
 
#define OLD_CSIDL_MYDOCUMENTS   0x000c
 
#define PT_CPL   0x01 /* no path */
 
#define PT_GUID   0x1f /* no path */
 
#define PT_DRIVE   0x23 /* has path */
 
#define PT_DRIVE2   0x25 /* has path */
 
#define PT_SHELLEXT   0x2e /* no path */
 
#define PT_FOLDER   0x31 /* has path */
 
#define PT_FOLDERW   0x35 /* has path */
 
#define PT_WORKGRP   0x41 /* no path */
 
#define PT_YAGUID   0x70 /* no path */
 
#define PT_IESPECIAL2   0xb1 /* has path */
 
#define DECLARE_TYPE(x, y)   { x, ARRAY_SIZE(y), y }
 
#define GET_PROC(func)
 
#define CSIDL_PROFILES   0x003e
 
#define CSIDL_TO_STR(x)   case x: return#x;
 
#define NO_CSIDL   0x10000
 
#define WINE_ATTRIBUTES_OPTIONAL   0x20000
 
#define KNOWN_FOLDER(id, csidl, name, category, parent1, parent2, relative_path, parsing_name, attributes, definitionFlags)    { &id, # id, csidl, # csidl, name, category, {&parent1, &parent2}, relative_path, parsing_name, attributes, definitionFlags, __LINE__ }
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
static HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO *)
 
static LPITEMIDLIST *static BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND
 
static LPITEMIDLIST *static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST)
 
static int (WINAPI *pSHFileOperationA)(LPSHFILEOPSTRUCTA)
 
static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR
 
static void loadShell32 (void)
 
static const chargetFolderName (int folder)
 
static void test_parameters (void)
 
static BYTE testSHGetFolderLocation (int folder)
 
static BYTE testSHGetSpecialFolderLocation (int folder)
 
static void test_SHGetFolderPath (BOOL optional, int folder)
 
static void test_SHGetSpecialFolderPath (BOOL optional, int folder)
 
static void test_ShellValues (const struct shellExpectedValues testEntries[], int numEntries, BOOL optional)
 
static void matchSpecialFolderPathToEnv (int folder, const char *envVar)
 
static void matchGUID (int folder, const GUID *guid, const GUID *guid_alt)
 
static void test_PidlTypes (void)
 
 DEFINE_GUID (CLSID_NetworkExplorerFolder, 0xF02C1A0D, 0xBE21, 0x4350, 0x88, 0xB0, 0x73, 0x67, 0xFC, 0x96, 0xEF, 0x3C)
 
 DEFINE_GUID (_CLSID_Documents, 0xA8CDFF1C, 0x4878, 0x43be, 0xB5, 0xFD, 0xF8, 0x09, 0x1C, 0x1C, 0x60, 0xD0)
 
static void test_GUIDs (void)
 
static void test_EnvVars (void)
 
static BOOL myPathIsRootA (LPCSTR lpszPath)
 
static LPSTR myPathRemoveBackslashA (LPSTR lpszPath)
 
static void testWinDir (void)
 
static void testSystemDir (void)
 
static BOOL init (void)
 
static void doChild (const char *arg)
 
static void test_NonExistentPath (void)
 
static void test_SHGetFolderPathEx (void)
 
static BOOL is_in_strarray (const WCHAR *needle, const char *hay)
 
static void check_known_folder (IKnownFolderManager *mgr, KNOWNFOLDERID *folderId)
 
static void test_knownFolders (void)
 
static void test_DoEnvironmentSubst (void)
 
static void test_PathYetAnotherMakeUniqueName (void)
 
static void test_SHGetKnownFolderIDList (void)
 
 START_TEST (shellpath)
 

Variables

static GUID CLSID_CommonDocuments = { 0x0000000c, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x1a } }
 
static int
 
static HANDLE
 
static DWORD
 
static LPSTR
 
static LPITEMIDLIST *static BOOL
 
static UINT
 
static PWSTR *static PWSTR
 
static LPWSTR
 
static PCWSTR
 
static PIDLIST_ABSOLUTE *static DLLVERSIONINFO shellVersion = { 0 }
 
static LPMALLOC pMalloc
 
static const BYTE guidType [] = { PT_GUID }
 
static const BYTE controlPanelType [] = { PT_SHELLEXT, PT_GUID, PT_CPL }
 
static const BYTE folderType [] = { PT_FOLDER, PT_FOLDERW }
 
static const BYTE favoritesType [] = { PT_FOLDER, PT_FOLDERW, 0, PT_IESPECIAL2 }
 
static const BYTE folderOrSpecialType [] = { PT_FOLDER, PT_IESPECIAL2 }
 
static const BYTE personalType []
 
static const BYTE printersType [] = { PT_YAGUID, PT_SHELLEXT, 0x71 }
 
static const BYTE ieSpecialType [] = { PT_IESPECIAL2 }
 
static const BYTE shellExtType [] = { PT_SHELLEXT }
 
static const BYTE workgroupType [] = { PT_WORKGRP }
 
static const struct shellExpectedValues requiredShellValues []
 
static const struct shellExpectedValues optionalShellValues []
 
static const GUID _FOLDERID_CryptoKeys = {0xB88F4DAA, 0xE7BD, 0x49A9, {0xB7, 0x4D, 0x02, 0x88, 0x5A, 0x5D, 0xC7, 0x65} }
 
static const GUID _FOLDERID_DpapiKeys = {0x10C07CD0, 0xEF91, 0x4567, {0xB8, 0x50, 0x44, 0x8B, 0x77, 0xCB, 0x37, 0xF9} }
 
static const GUID _FOLDERID_SystemCertificates = {0x54EED2E0, 0xE7CA, 0x4FDB, {0x91, 0x48, 0x0F, 0x42, 0x47, 0x29, 0x1C, 0xFA} }
 
static const GUID _FOLDERID_CredentialManager = {0x915221FB, 0x9EFE, 0x4BDA, {0x8F, 0xD7, 0xF7, 0x8D, 0xCA, 0x77, 0x4F, 0x87} }
 
static const struct knownFolderDef known_folders []
 
BOOL known_folder_found [ARRAY_SIZE(known_folders)]
 
static int myARGC
 
static char ** myARGV
 
static char base [MAX_PATH]
 
static char selfname [MAX_PATH]
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file shellpath.c.

◆ CSIDL_PROFILES

#define CSIDL_PROFILES   0x003e

Definition at line 231 of file shellpath.c.

◆ CSIDL_TO_STR

#define CSIDL_TO_STR (   x)    case x: return#x;

◆ DECLARE_TYPE

#define DECLARE_TYPE (   x,
  y 
)    { x, ARRAY_SIZE(y), y }

Definition at line 117 of file shellpath.c.

◆ GET_PROC

#define GET_PROC (   func)
Value:
p ## func = (void*)GetProcAddress(hShell32, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
#define GetProcAddress(x, y)
Definition: compat.h:753
GLenum func
Definition: glext.h:6028
GLfloat GLfloat p
Definition: glext.h:8902
static HMODULE hShell32
Definition: string.c:34

◆ KNOWN_FOLDER

#define KNOWN_FOLDER (   id,
  csidl,
  name,
  category,
  parent1,
  parent2,
  relative_path,
  parsing_name,
  attributes,
  definitionFlags 
)     { &id, # id, csidl, # csidl, name, category, {&parent1, &parent2}, relative_path, parsing_name, attributes, definitionFlags, __LINE__ }

Definition at line 310 of file shellpath.c.

◆ NO_CSIDL

#define NO_CSIDL   0x10000

Definition at line 308 of file shellpath.c.

◆ OLD_CSIDL_MYDOCUMENTS

#define OLD_CSIDL_MYDOCUMENTS   0x000c

Definition at line 42 of file shellpath.c.

◆ PT_CPL

#define PT_CPL   0x01 /* no path */

Definition at line 48 of file shellpath.c.

◆ PT_DRIVE

#define PT_DRIVE   0x23 /* has path */

Definition at line 54 of file shellpath.c.

◆ PT_DRIVE2

#define PT_DRIVE2   0x25 /* has path */

Definition at line 57 of file shellpath.c.

◆ PT_FOLDER

#define PT_FOLDER   0x31 /* has path */

Definition at line 63 of file shellpath.c.

◆ PT_FOLDERW

#define PT_FOLDERW   0x35 /* has path */

Definition at line 66 of file shellpath.c.

◆ PT_GUID

#define PT_GUID   0x1f /* no path */

Definition at line 51 of file shellpath.c.

◆ PT_IESPECIAL2

#define PT_IESPECIAL2   0xb1 /* has path */

Definition at line 76 of file shellpath.c.

◆ PT_SHELLEXT

#define PT_SHELLEXT   0x2e /* no path */

Definition at line 60 of file shellpath.c.

◆ PT_WORKGRP

#define PT_WORKGRP   0x41 /* no path */

Definition at line 69 of file shellpath.c.

◆ PT_YAGUID

#define PT_YAGUID   0x70 /* no path */

Definition at line 72 of file shellpath.c.

◆ WINE_ATTRIBUTES_OPTIONAL

#define WINE_ATTRIBUTES_OPTIONAL   0x20000

Definition at line 309 of file shellpath.c.

Function Documentation

◆ BOOL()

static LPITEMIDLIST *static BOOL ( WINAPI pSHGetSpecialFolderPathA)
static

◆ check_known_folder()

static void check_known_folder ( IKnownFolderManager mgr,
KNOWNFOLDERID folderId 
)
static

Definition at line 1991 of file shellpath.c.

1992{
1993 HRESULT hr;
1994 int csidl, expectedCsidl, ret;
1996 IKnownFolder *folder;
1997 WCHAR sName[1024];
1998 BOOL found = FALSE;
1999 unsigned int i;
2000
2001 for (i = 0; i < ARRAY_SIZE(known_folders); ++i)
2002 {
2003 const struct knownFolderDef *known_folder = &known_folders[i];
2004
2005 if(IsEqualGUID(known_folder->folderId, folderId))
2006 {
2008 found = TRUE;
2009 /* verify CSIDL */
2010 if(!(known_folder->csidl & NO_CSIDL))
2011 {
2012 /* mask off winetest flags */
2013 expectedCsidl = known_folder->csidl & 0xFFFF;
2014
2015 hr = IKnownFolderManager_FolderIdToCsidl(mgr, folderId, &csidl);
2016 ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot retrieve CSIDL for folder %s\n", known_folder->sFolderId);
2017
2018 ok_(__FILE__, known_folder->line)(csidl == expectedCsidl, "invalid CSIDL retrieved for folder %s. %d (%s) expected, but %d found\n", known_folder->sFolderId, expectedCsidl, known_folder->sCsidl, csidl);
2019 }
2020
2021 hr = IKnownFolderManager_GetFolder(mgr, folderId, &folder);
2022 ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot get known folder for %s\n", known_folder->sFolderId);
2023 if(SUCCEEDED(hr))
2024 {
2025 hr = IKnownFolder_GetFolderDefinition(folder, &kfd);
2026 ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot get known folder definition for %s\n", known_folder->sFolderId);
2027 if(SUCCEEDED(hr))
2028 {
2029 ret = MultiByteToWideChar(CP_ACP, 0, known_folder->sName, -1, sName, ARRAY_SIZE(sName));
2030 ok_(__FILE__, known_folder->line)(ret != 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder->sName);
2031
2032 ok_(__FILE__, known_folder->line)(lstrcmpW(kfd.pszName, sName)==0, "invalid known folder name returned for %s: %s expected, but %s retrieved\n", known_folder->sFolderId, wine_dbgstr_w(sName), wine_dbgstr_w(kfd.pszName));
2033
2034 ok_(__FILE__, known_folder->line)(kfd.category == known_folder->category, "invalid known folder category for %s: %d expected, but %d retrieved\n", known_folder->sFolderId, known_folder->category, kfd.category);
2035
2036 ok_(__FILE__, known_folder->line)(IsEqualGUID(known_folder->fidParents[0], &kfd.fidParent) ||
2037 IsEqualGUID(known_folder->fidParents[1], &kfd.fidParent),
2038 "invalid known folder parent for %s: %s retrieved\n",
2039 known_folder->sFolderId, wine_dbgstr_guid(&kfd.fidParent));
2040
2041 ok_(__FILE__, known_folder->line)(is_in_strarray(kfd.pszRelativePath, known_folder->sRelativePath), "invalid known folder relative path returned for %s: %s expected, but %s retrieved\n", known_folder->sFolderId, known_folder->sRelativePath, wine_dbgstr_w(kfd.pszRelativePath));
2042
2043 ok_(__FILE__, known_folder->line)(is_in_strarray(kfd.pszParsingName, known_folder->sParsingName), "invalid known folder parsing name returned for %s: %s retrieved\n", known_folder->sFolderId, wine_dbgstr_w(kfd.pszParsingName));
2044
2045 ok_(__FILE__, known_folder->line)(known_folder->attributes == kfd.dwAttributes ||
2046 (known_folder->csidl & WINE_ATTRIBUTES_OPTIONAL && kfd.dwAttributes == 0),
2047 "invalid known folder attributes for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder->sFolderId, known_folder->attributes, kfd.dwAttributes);
2048
2049 ok_(__FILE__, known_folder->line)(!(kfd.kfdFlags & (~known_folder->definitionFlags)), "invalid known folder flags for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder->sFolderId, known_folder->definitionFlags, kfd.kfdFlags);
2050
2052 }
2053
2054 IKnownFolder_Release(folder);
2055 }
2056
2057 break;
2058 }
2059 }
2060
2061 if(!found)
2062 {
2063 trace("unknown known folder found: %s\n", wine_dbgstr_guid(folderId));
2064
2065 hr = IKnownFolderManager_GetFolder(mgr, folderId, &folder);
2066 ok(hr == S_OK, "cannot get known folder for %s\n", wine_dbgstr_guid(folderId));
2067 if(SUCCEEDED(hr))
2068 {
2069 hr = IKnownFolder_GetFolderDefinition(folder, &kfd);
2070 todo_wine
2071 ok(hr == S_OK, "cannot get known folder definition for %s\n", wine_dbgstr_guid(folderId));
2072 if(SUCCEEDED(hr))
2073 {
2074 trace(" category: %d\n", kfd.category);
2075 trace(" name: %s\n", wine_dbgstr_w(kfd.pszName));
2076 trace(" description: %s\n", wine_dbgstr_w(kfd.pszDescription));
2077 trace(" parent: %s\n", wine_dbgstr_guid(&kfd.fidParent));
2078 trace(" relative path: %s\n", wine_dbgstr_w(kfd.pszRelativePath));
2079 trace(" parsing name: %s\n", wine_dbgstr_w(kfd.pszParsingName));
2080 trace(" tooltip: %s\n", wine_dbgstr_w(kfd.pszTooltip));
2081 trace(" localized name: %s\n", wine_dbgstr_w(kfd.pszLocalizedName));
2082 trace(" icon: %s\n", wine_dbgstr_w(kfd.pszIcon));
2083 trace(" security: %s\n", wine_dbgstr_w(kfd.pszSecurity));
2084 trace(" attributes: 0x%08x\n", kfd.dwAttributes);
2085 trace(" flags: 0x%08x\n", kfd.kfdFlags);
2086 trace(" type: %s\n", wine_dbgstr_guid(&kfd.ftidType));
2088 }
2089
2090 IKnownFolder_Release(folder);
2091 }
2092 }
2093}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define ok_(x1, x2)
Definition: atltest.h:61
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT hr
Definition: delayimp.cpp:582
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define wine_dbgstr_w
Definition: kernel32.h:34
#define todo_wine
Definition: minitest.h:80
#define NO_CSIDL
Definition: shellpath.c:308
static BOOL is_in_strarray(const WCHAR *needle, const char *hay)
Definition: shellpath.c:1961
BOOL known_folder_found[ARRAY_SIZE(known_folders)]
Definition: shellpath.c:1335
#define WINE_ATTRIBUTES_OPTIONAL
Definition: shellpath.c:309
static const struct knownFolderDef known_folders[]
Definition: shellpath.c:343
short WCHAR
Definition: pedump.c:58
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:171
static void FreeKnownFolderDefinitionFields(KNOWNFOLDER_DEFINITION *pKFD)
Definition: shobjidl.idl:4182
Definition: fci.c:116
const DWORD attributes
Definition: shellpath.c:329
const char * sRelativePath
Definition: shellpath.c:327
const KF_CATEGORY category
Definition: shellpath.c:325
const int csidl
Definition: shellpath.c:322
const KNOWNFOLDERID * folderId
Definition: shellpath.c:320
const char * sFolderId
Definition: shellpath.c:321
const char * sName
Definition: shellpath.c:324
const KF_DEFINITION_FLAGS definitionFlags
Definition: shellpath.c:330
const char * sCsidl
Definition: shellpath.c:323
const int line
Definition: shellpath.c:331
const KNOWNFOLDERID * fidParents[2]
Definition: shellpath.c:326
const char * sParsingName
Definition: shellpath.c:328
KF_DEFINITION_FLAGS kfdFlags
Definition: shobjidl.idl:4063

Referenced by test_knownFolders().

◆ DEFINE_GUID() [1/3]

DEFINE_GUID ( _CLSID_Documents  ,
0xA8CDFF1C  ,
0x4878  ,
0x43be  ,
0xB5  ,
0xFD  ,
0xF8  ,
0x09  ,
0x1C  ,
0x1C  ,
0x60  ,
0xD0   
)

◆ DEFINE_GUID() [2/3]

DEFINE_GUID ( CLSID_NetworkExplorerFolder  ,
0xF02C1A0D  ,
0xBE21  ,
0x4350  ,
0x88  ,
0xB0  ,
0x73  ,
0x67  ,
0xFC  ,
0x96  ,
0xEF  ,
0x3C   
)

◆ DEFINE_GUID() [3/3]

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ doChild()

static void doChild ( const char arg)
static

Definition at line 1717 of file shellpath.c.

1718{
1719 char path[MAX_PATH];
1720 HRESULT hr;
1721
1722 if (arg[0] == '1')
1723 {
1724 LPITEMIDLIST pidl;
1725 char *p;
1726
1727 /* test what happens when CSIDL_FAVORITES is set to a nonexistent directory */
1728
1729 /* test some failure cases first: */
1730 hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES, NULL, SHGFP_TYPE_CURRENT, path);
1732 "SHGetFolderPath returned 0x%08x, expected 0x80070002\n", hr);
1733
1734 pidl = NULL;
1735 hr = pSHGetFolderLocation(NULL, CSIDL_FAVORITES, NULL, 0, &pidl);
1737 "SHGetFolderLocation returned 0x%08x\n", hr);
1738 if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
1739
1740 ok(!pSHGetSpecialFolderPathA(NULL, path, CSIDL_FAVORITES, FALSE),
1741 "SHGetSpecialFolderPath succeeded, expected failure\n");
1742
1743 pidl = NULL;
1744 hr = pSHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
1746 "SHGetFolderLocation returned 0x%08x\n", hr);
1747
1748 if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
1749
1750 /* now test success: */
1751 hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES | CSIDL_FLAG_CREATE, NULL,
1753 ok (hr == S_OK, "got 0x%08x\n", hr);
1754 if (hr == S_OK)
1755 {
1756 BOOL ret;
1757
1758 trace("CSIDL_FAVORITES was changed to %s\n", path);
1760 ok(!ret, "expected failure with ERROR_ALREADY_EXISTS\n");
1761 if (!ret)
1763 "got %d, expected ERROR_ALREADY_EXISTS\n", GetLastError());
1764
1765 p = path + strlen(path);
1766 strcpy(p, "\\desktop.ini");
1768 *p = 0;
1771 ok( ret, "failed to remove %s error %u\n", path, GetLastError() );
1772 }
1773 }
1774 else if (arg[0] == '2')
1775 {
1776 /* make sure SHGetFolderPath still succeeds when the
1777 original value of CSIDL_FAVORITES is restored. */
1778 hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES | CSIDL_FLAG_CREATE, NULL,
1780 ok(hr == S_OK, "SHGetFolderPath failed: 0x%08x\n", hr);
1781 }
1782}
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:682
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:760
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static LPMALLOC pMalloc
Definition: shellpath.c:104
strcpy
Definition: string.h:131
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2166
#define CSIDL_FAVORITES
Definition: shlobj.h:2196
#define CSIDL_FLAG_CREATE
Definition: shlobj.h:2252
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by START_TEST().

◆ getFolderName()

static const char * getFolderName ( int  folder)
static

Definition at line 235 of file shellpath.c.

236{
237 static char unknown[32];
238
239#define CSIDL_TO_STR(x) case x: return#x;
240 switch (folder)
241 {
300#undef CSIDL_TO_STR
301 default:
302 sprintf(unknown, "unknown (0x%04x)", folder);
303 return unknown;
304 }
305}
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674
#define sprintf
Definition: sprintf.c:45
#define OLD_CSIDL_MYDOCUMENTS
Definition: shellpath.c:42
#define CSIDL_PROFILES
Definition: shellpath.c:231
#define CSIDL_TO_STR(x)
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2234
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2214
#define CSIDL_TEMPLATES
Definition: shlobj.h:2210
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2227
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2221
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2205
#define CSIDL_SENDTO
Definition: shlobj.h:2199
#define CSIDL_RECENT
Definition: shlobj.h:2198
#define CSIDL_ADMINTOOLS
Definition: shlobj.h:2237
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2211
#define CSIDL_CDBURN_AREA
Definition: shlobj.h:2245
#define CSIDL_COMMON_ALTSTARTUP
Definition: shlobj.h:2219
#define CSIDL_FONTS
Definition: shlobj.h:2209
#define CSIDL_PERSONAL
Definition: shlobj.h:2195
#define CSIDL_COMMON_APPDATA
Definition: shlobj.h:2224
#define CSIDL_CONNECTIONS
Definition: shlobj.h:2238
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2212
#define CSIDL_COMPUTERSNEARME
Definition: shlobj.h:2246
#define CSIDL_MYPICTURES
Definition: shlobj.h:2228
#define CSIDL_COOKIES
Definition: shlobj.h:2222
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2220
#define CSIDL_PRINTERS
Definition: shlobj.h:2194
#define CSIDL_RESOURCES
Definition: shlobj.h:2242
#define CSIDL_SYSTEM
Definition: shlobj.h:2226
#define CSIDL_HISTORY
Definition: shlobj.h:2223
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2217
#define CSIDL_PROFILE
Definition: shlobj.h:2229
#define CSIDL_PROGRAM_FILES_COMMONX86
Definition: shlobj.h:2233
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2232
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2239
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2241
#define CSIDL_DESKTOP
Definition: shlobj.h:2190
#define CSIDL_NETWORK
Definition: shlobj.h:2207
#define CSIDL_STARTMENU
Definition: shlobj.h:2201
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2231
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2240
#define CSIDL_PROGRAMS
Definition: shlobj.h:2192
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2213
#define CSIDL_APPDATA
Definition: shlobj.h:2215
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2216
#define CSIDL_ALTSTARTUP
Definition: shlobj.h:2218
#define CSIDL_SYSTEMX86
Definition: shlobj.h:2230
#define CSIDL_STARTUP
Definition: shlobj.h:2197
#define CSIDL_WINDOWS
Definition: shlobj.h:2225
#define CSIDL_DRIVES
Definition: shlobj.h:2206
#define CSIDL_MYMUSIC
Definition: shlobj.h:2203
#define CSIDL_INTERNET
Definition: shlobj.h:2191
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2235
#define CSIDL_CONTROLS
Definition: shlobj.h:2193
#define CSIDL_BITBUCKET
Definition: shlobj.h:2200
#define CSIDL_NETHOOD
Definition: shlobj.h:2208
#define CSIDL_COMMON_OEM_LINKS
Definition: shlobj.h:2244
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2236
#define CSIDL_MYVIDEO
Definition: shlobj.h:2204
#define CSIDL_RESOURCES_LOCALIZED
Definition: shlobj.h:2243

Referenced by matchGUID(), test_ShellValues(), test_SHGetFolderPath(), test_SHGetSpecialFolderPath(), testSHGetFolderLocation(), and testSHGetSpecialFolderLocation().

◆ HRESULT()

static HRESULT ( WINAPI pDllGetVersion)
static

◆ init()

static BOOL init ( void  )
static

Definition at line 1709 of file shellpath.c.

1710{
1712 if (!GetCurrentDirectoryA(sizeof(base), base)) return FALSE;
1713 strcpy(selfname, myARGV[0]);
1714 return TRUE;
1715}
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2065
static int myARGC
Definition: shellpath.c:1704
static char ** myARGV
Definition: shellpath.c:1705
static char selfname[MAX_PATH]
Definition: shellpath.c:1707
int winetest_get_mainargs(char ***pargv)

Referenced by START_TEST().

◆ int()

static int ( WINAPI pSHFileOperationA)
static

◆ is_in_strarray()

static BOOL is_in_strarray ( const WCHAR needle,
const char hay 
)
static

Definition at line 1961 of file shellpath.c.

1962{
1963 WCHAR wstr[MAX_PATH];
1964
1965 if(!needle && !hay)
1966 return TRUE;
1967
1968 while(hay && *hay)
1969 {
1970 DWORD ret;
1971
1972 if(strcmp(hay, "(null)") == 0 && !needle)
1973 return TRUE;
1974
1975 ret = MultiByteToWideChar(CP_ACP, 0, hay, -1, wstr, ARRAY_SIZE(wstr));
1976 if(ret == 0)
1977 {
1978 ok(0, "Failed to convert string\n");
1979 return FALSE;
1980 }
1981
1982 if(lstrcmpW(wstr, needle) == 0)
1983 return TRUE;
1984
1985 hay += strlen(hay) + 1;
1986 }
1987
1988 return FALSE;
1989}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by check_known_folder().

◆ loadShell32()

static void loadShell32 ( void  )
static

Definition at line 186 of file shellpath.c.

187{
188 HMODULE hShell32 = GetModuleHandleA("shell32");
189
190#define GET_PROC(func) \
191 p ## func = (void*)GetProcAddress(hShell32, #func); \
192 if(!p ## func) \
193 trace("GetProcAddress(%s) failed\n", #func);
194
197 GET_PROC(SHGetFolderPathEx)
199 GET_PROC(SHGetKnownFolderPath)
200 GET_PROC(SHSetKnownFolderPath)
204 if (!pILFindLastID)
205 pILFindLastID = (void *)GetProcAddress(hShell32, (LPCSTR)16);
209 GET_PROC(SHGetKnownFolderIDList)
210
211 ok(pSHGetMalloc != NULL, "shell32 is missing SHGetMalloc\n");
212 if (pSHGetMalloc)
213 {
214 HRESULT hr = pSHGetMalloc(&pMalloc);
215
216 ok(hr == S_OK, "SHGetMalloc failed: 0x%08x\n", hr);
217 ok(pMalloc != NULL, "SHGetMalloc returned a NULL IMalloc\n");
218 }
219
220 if (pDllGetVersion)
221 {
222 shellVersion.cbSize = sizeof(shellVersion);
223 pDllGetVersion(&shellVersion);
224 trace("shell32 version is %d.%d\n",
225 shellVersion.dwMajorVersion, shellVersion.dwMinorVersion);
226 }
227#undef GET_PROC
228}
STDAPI DllGetVersion(DLLVERSIONINFO *info)
Definition: browseui.cpp:221
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal)
Definition: shellole.c:329
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3384
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3277
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3206
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2963
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:848
static PIDLIST_ABSOLUTE *static DLLVERSIONINFO shellVersion
Definition: shellpath.c:103
#define GET_PROC(func)
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:199
int WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
Definition: shlfileop.cpp:1160
const char * LPCSTR
Definition: typedefs.h:52

Referenced by START_TEST().

◆ LPITEMIDLIST()

static LPITEMIDLIST *static LPITEMIDLIST ( WINAPI pILFindLastID)
static

◆ matchGUID()

static void matchGUID ( int  folder,
const GUID guid,
const GUID guid_alt 
)
static

Definition at line 1553 of file shellpath.c.

1554{
1555 LPITEMIDLIST pidl;
1556 HRESULT hr;
1557
1558 if (!pSHGetFolderLocation) return;
1559 if (!guid) return;
1560
1561 pidl = NULL;
1562 hr = pSHGetFolderLocation(NULL, folder, NULL, 0, &pidl);
1563 if (hr == S_OK)
1564 {
1565 LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1566
1567 if (pidlLast && (pidlLast->mkid.abID[0] == PT_SHELLEXT ||
1568 pidlLast->mkid.abID[0] == PT_GUID))
1569 {
1570 GUID *shellGuid = (GUID *)(pidlLast->mkid.abID + 2);
1571
1572 if (!guid_alt)
1573 ok(IsEqualIID(shellGuid, guid),
1574 "%s: got GUID %s, expected %s\n", getFolderName(folder),
1576 else
1577 ok(IsEqualIID(shellGuid, guid) ||
1578 IsEqualIID(shellGuid, guid_alt),
1579 "%s: got GUID %s, expected %s or %s\n", getFolderName(folder),
1580 wine_dbgstr_guid(shellGuid), wine_dbgstr_guid(guid), wine_dbgstr_guid(guid_alt));
1581 }
1582 IMalloc_Free(pMalloc, pidl);
1583 }
1584}
GUID guid
Definition: version.c:147
static const char * getFolderName(int folder)
Definition: shellpath.c:235
#define PT_GUID
Definition: shellpath.c:51
#define PT_SHELLEXT
Definition: shellpath.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by test_GUIDs().

◆ matchSpecialFolderPathToEnv()

static void matchSpecialFolderPathToEnv ( int  folder,
const char envVar 
)
static

Definition at line 1531 of file shellpath.c.

1532{
1533 char path[MAX_PATH];
1534
1535 if (!pSHGetSpecialFolderPathA) return;
1536
1537 if (pSHGetSpecialFolderPathA(NULL, path, folder, FALSE))
1538 {
1539 char *envVal = getenv(envVar);
1540
1541 ok(!envVal || !lstrcmpiA(envVal, path),
1542 "%%%s%% does not match SHGetSpecialFolderPath:\n"
1543 "%%%s%% is %s\nSHGetSpecialFolderPath returns %s\n",
1544 envVar, envVar, envVal, path);
1545 }
1546}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
char *CDECL getenv(const char *name)
Definition: environ.c:227

Referenced by test_EnvVars().

◆ myPathIsRootA()

static BOOL myPathIsRootA ( LPCSTR  lpszPath)
static

Definition at line 1630 of file shellpath.c.

1631{
1632 if (lpszPath && *lpszPath &&
1633 lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
1634 return TRUE; /* X:\ */
1635 return FALSE;
1636}

Referenced by myPathRemoveBackslashA().

◆ myPathRemoveBackslashA()

static LPSTR myPathRemoveBackslashA ( LPSTR  lpszPath)
static

Definition at line 1637 of file shellpath.c.

1638{
1639 LPSTR szTemp = NULL;
1640
1641 if(lpszPath)
1642 {
1643 szTemp = CharPrevA(lpszPath, lpszPath + strlen(lpszPath));
1644 if (!myPathIsRootA(lpszPath) && *szTemp == '\\')
1645 *szTemp = '\0';
1646 }
1647 return szTemp;
1648}
LPSTR WINAPI CharPrevA(const char *start, const char *ptr)
Definition: string.c:1172
static BOOL myPathIsRootA(LPCSTR lpszPath)
Definition: shellpath.c:1630
char * LPSTR
Definition: typedefs.h:51

Referenced by testSystemDir(), and testWinDir().

◆ START_TEST()

START_TEST ( shellpath  )

Definition at line 2869 of file shellpath.c.

2870{
2871 if (!init()) return;
2872
2873 loadShell32();
2874 pGetSystemWow64DirectoryA = (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
2875 "GetSystemWow64DirectoryA" );
2876 if (myARGC >= 3)
2877 doChild(myARGV[2]);
2878 else
2879 {
2880 /* Report missing functions once */
2881 if (!pSHGetFolderLocation)
2882 win_skip("SHGetFolderLocation is not available\n");
2883
2884 /* first test various combinations of parameters: */
2886
2887 /* check known values: */
2889 test_GUIDs();
2890 test_EnvVars();
2891 testWinDir();
2892 testSystemDir();
2899 }
2900}
#define win_skip
Definition: minitest.h:67
static void test_SHGetKnownFolderIDList(void)
Definition: shellpath.c:2813
static void testSystemDir(void)
Definition: shellpath.c:1675
static void test_PidlTypes(void)
Definition: shellpath.c:1587
static void test_DoEnvironmentSubst(void)
Definition: shellpath.c:2584
static void test_NonExistentPath(void)
Definition: shellpath.c:1797
static void test_SHGetFolderPathEx(void)
Definition: shellpath.c:1866
static void test_EnvVars(void)
Definition: shellpath.c:1617
static BOOL init(void)
Definition: shellpath.c:1709
static void test_PathYetAnotherMakeUniqueName(void)
Definition: shellpath.c:2734
static void test_parameters(void)
Definition: shellpath.c:1337
static void loadShell32(void)
Definition: shellpath.c:186
static void test_knownFolders(void)
Definition: shellpath.c:2096
static void doChild(const char *arg)
Definition: shellpath.c:1717
static void test_GUIDs(void)
Definition: shellpath.c:1602
static void testWinDir(void)
Definition: shellpath.c:1654

◆ test_DoEnvironmentSubst()

static void test_DoEnvironmentSubst ( void  )
static

Definition at line 2584 of file shellpath.c.

2585{
2586 WCHAR expectedW[MAX_PATH];
2587 WCHAR bufferW[MAX_PATH];
2588 CHAR expectedA[MAX_PATH];
2589 CHAR bufferA[MAX_PATH];
2590 DWORD res;
2591 DWORD res2;
2592 DWORD len;
2593 INT i;
2594 static const WCHAR does_not_existW[] = {'%','D','O','E','S','_','N','O','T','_','E','X','I','S','T','%',0};
2595 static const CHAR does_not_existA[] = "%DOES_NOT_EXIST%";
2596 static const CHAR *names[] = {
2597 /* interactive apps and services (works on all windows versions) */
2598 "%ALLUSERSPROFILE%", "%APPDATA%", "%LOCALAPPDATA%",
2599 "%NUMBER_OF_PROCESSORS%", "%OS%", "%PROCESSOR_ARCHITECTURE%",
2600 "%PROCESSOR_IDENTIFIER%", "%PROCESSOR_LEVEL%", "%PROCESSOR_REVISION%",
2601 "%ProgramFiles%", "%SystemDrive%",
2602 "%SystemRoot%", "%USERPROFILE%", "%windir%",
2603 /* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
2604
2605 /* replace more than one var is allowed */
2606 "%HOMEDRIVE%%HOMEPATH%",
2607 "%OS% %windir%"}; /* always the last entry in the table */
2608
2609 for (i = 0; i < (ARRAY_SIZE(names)); i++)
2610 {
2611 memset(bufferA, '#', MAX_PATH - 1);
2612 bufferA[MAX_PATH - 1] = 0;
2613 lstrcpyA(bufferA, names[i]);
2614 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2615
2616 res2 = ExpandEnvironmentStringsA(names[i], expectedA, MAX_PATH);
2617 res = DoEnvironmentSubstA(bufferA, MAX_PATH);
2618
2619 /* is the space for the terminating 0 included? */
2620 if (!i && HIWORD(res) && (LOWORD(res) == (lstrlenA(bufferA))))
2621 {
2622 win_skip("DoEnvironmentSubstA/W are broken on NT 4\n");
2623 return;
2624 }
2625 ok(HIWORD(res) && (LOWORD(res) == res2),
2626 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2627 ok(!lstrcmpA(bufferA, expectedA),
2628 "%d: got %s (expected %s)\n", i, bufferA, expectedA);
2629
2630 res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2631 res = DoEnvironmentSubstW(bufferW, MAX_PATH);
2632 ok(HIWORD(res) && (LOWORD(res) == res2),
2633 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2634 ok(!lstrcmpW(bufferW, expectedW),
2635 "%d: got %s (expected %s)\n", i, wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2636 }
2637
2638 i--; /* reuse data in the last table entry */
2639 len = LOWORD(res); /* needed length */
2640
2641 /* one character extra is fine */
2642 memset(bufferA, '#', MAX_PATH - 1);
2643 bufferA[len + 2] = 0;
2644 lstrcpyA(bufferA, names[i]);
2645 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2646
2647 res2 = ExpandEnvironmentStringsA(bufferA, expectedA, MAX_PATH);
2648 res = DoEnvironmentSubstA(bufferA, len + 1);
2649 ok(HIWORD(res) && (LOWORD(res) == res2),
2650 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2651 ok(!lstrcmpA(bufferA, expectedA),
2652 "+1: got %s (expected %s)\n", bufferA, expectedA);
2653
2654 res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2655 res = DoEnvironmentSubstW(bufferW, len + 1);
2656 ok(HIWORD(res) && (LOWORD(res) == res2),
2657 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2658 ok(!lstrcmpW(bufferW, expectedW),
2659 "+1: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2660
2661
2662 /* minimal buffer length (result string and terminating 0) */
2663 memset(bufferA, '#', MAX_PATH - 1);
2664 bufferA[len + 2] = 0;
2665 lstrcpyA(bufferA, names[i]);
2666 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2667
2668 /* ANSI version failed without an extra byte, as documented on msdn */
2669 res = DoEnvironmentSubstA(bufferA, len);
2670 ok(!HIWORD(res) && (LOWORD(res) == len),
2671 " 0: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len);
2672 ok(!lstrcmpA(bufferA, names[i]),
2673 " 0: got %s (expected %s)\n", bufferA, names[i]);
2674
2675 /* DoEnvironmentSubstW works as expected */
2676 res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2677 res = DoEnvironmentSubstW(bufferW, len);
2678 ok(HIWORD(res) && (LOWORD(res) == res2),
2679 " 0: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2680 ok(!lstrcmpW(bufferW, expectedW),
2681 " 0: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2682
2683
2684 /* Buffer too small */
2685 /* result: FALSE / provided buffer length / the buffer is untouched */
2686 memset(bufferA, '#', MAX_PATH - 1);
2687 bufferA[len + 2] = 0;
2688 lstrcpyA(bufferA, names[i]);
2689 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2690
2691 res = DoEnvironmentSubstA(bufferA, len - 1);
2692 ok(!HIWORD(res) && (LOWORD(res) == (len - 1)),
2693 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len - 1);
2694 ok(!lstrcmpA(bufferA, names[i]),
2695 "-1: got %s (expected %s)\n", bufferA, names[i]);
2696
2697 lstrcpyW(expectedW, bufferW);
2698 res = DoEnvironmentSubstW(bufferW, len - 1);
2699 ok(!HIWORD(res) && (LOWORD(res) == (len - 1)),
2700 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len - 1);
2701 ok(!lstrcmpW(bufferW, expectedW),
2702 "-1: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2703
2704
2705 /* unknown variable */
2706 /* result: TRUE / string length including terminating 0 / the buffer is untouched */
2707 memset(bufferA, '#', MAX_PATH - 1);
2708 bufferA[MAX_PATH - 1] = 0;
2709 lstrcpyA(bufferA, does_not_existA);
2710 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2711
2712 res2 = lstrlenA(does_not_existA) + 1;
2713 res = DoEnvironmentSubstA(bufferA, MAX_PATH);
2714 ok(HIWORD(res) && (LOWORD(res) == res2),
2715 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2716 ok(!lstrcmpA(bufferA, does_not_existA),
2717 "%d: got %s (expected %s)\n", i, bufferA, does_not_existA);
2718
2719 res = DoEnvironmentSubstW(bufferW, MAX_PATH);
2720 ok(HIWORD(res) && (LOWORD(res) == res2),
2721 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2722 ok(!lstrcmpW(bufferW, does_not_existW),
2723 "%d: got %s (expected %s)\n", i, wine_dbgstr_w(bufferW), wine_dbgstr_w(does_not_existW));
2724
2725
2726 if (0)
2727 {
2728 /* NULL crashes on windows */
2731 }
2732}
#define lstrcpyW
Definition: compat.h:749
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:372
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
GLuint res
Definition: glext.h:9613
GLuint GLuint * names
Definition: glext.h:11545
GLenum GLsizei len
Definition: glext.h:6722
static WCHAR does_not_existW[]
Definition: localmon.c:90
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define LOWORD(l)
Definition: pedump.c:82
char CHAR
Definition: pedump.c:57
#define memset(x, y, z)
Definition: compat.h:39
DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
Definition: shellord.c:2073
DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
Definition: shellord.c:2028
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by START_TEST().

◆ test_EnvVars()

static void test_EnvVars ( void  )
static

Definition at line 1617 of file shellpath.c.

1618{
1625 /* this is only set on Wine, but can't hurt to verify it: */
1627}
static void matchSpecialFolderPathToEnv(int folder, const char *envVar)
Definition: shellpath.c:1531

Referenced by START_TEST().

◆ test_GUIDs()

static void test_GUIDs ( void  )
static

Definition at line 1602 of file shellpath.c.

1603{
1604 matchGUID(CSIDL_BITBUCKET, &CLSID_RecycleBin, NULL);
1605 matchGUID(CSIDL_CONTROLS, &CLSID_ControlPanel, NULL);
1606 matchGUID(CSIDL_DRIVES, &CLSID_MyComputer, NULL);
1607 matchGUID(CSIDL_INTERNET, &CLSID_Internet, NULL);
1608 matchGUID(CSIDL_NETWORK, &CLSID_NetworkPlaces, &CLSID_NetworkExplorerFolder); /* Vista and higher */
1609 matchGUID(CSIDL_PERSONAL, &CLSID_MyDocuments, &_CLSID_Documents /* win8 */);
1611 matchGUID(CSIDL_PRINTERS, &CLSID_Printers, NULL);
1612}
static void matchGUID(int folder, const GUID *guid, const GUID *guid_alt)
Definition: shellpath.c:1553
static GUID CLSID_CommonDocuments
Definition: shellpath.c:79

Referenced by START_TEST().

◆ test_knownFolders()

static void test_knownFolders ( void  )
static

Definition at line 2096 of file shellpath.c.

2097{
2098 static const WCHAR sWindows[] = {'W','i','n','d','o','w','s',0};
2099 static const WCHAR sWindows2[] = {'w','i','n','d','o','w','s',0};
2100 static const WCHAR sExample[] = {'E','x','a','m','p','l','e',0};
2101 static const WCHAR sExample2[] = {'E','x','a','m','p','l','e','2',0};
2102 static const WCHAR sSubFolder[] = {'S','u','b','F','o','l','d','e','r',0};
2103 static const WCHAR sNoSuch[] = {'N','o','S','u','c','h',0};
2104 static const WCHAR sBackslash[] = {'\\',0};
2105 static const KNOWNFOLDERID newFolderId = {0x01234567, 0x89AB, 0xCDEF, {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x01} };
2106 static const KNOWNFOLDERID subFolderId = {0xFEDCBA98, 0x7654, 0x3210, {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF} };
2107 HRESULT hr;
2109 IKnownFolder *folder = NULL, *subFolder = NULL;
2110 KNOWNFOLDERID folderId, *folders;
2111 KF_CATEGORY cat = 0;
2112 KNOWNFOLDER_DEFINITION kfDefinition, kfSubDefinition;
2113 int csidl, i;
2114 UINT nCount = 0;
2115 LPWSTR folderPath, errorMsg;
2116 KF_REDIRECTION_CAPABILITIES redirectionCapabilities = 1;
2117 WCHAR sWinDir[MAX_PATH], sExamplePath[MAX_PATH], sExample2Path[MAX_PATH], sSubFolderPath[MAX_PATH], sSubFolder2Path[MAX_PATH];
2118 BOOL bRes;
2120
2121 GetWindowsDirectoryW( sWinDir, MAX_PATH );
2122
2123 GetTempPathW(ARRAY_SIZE(sExamplePath), sExamplePath);
2124 lstrcatW(sExamplePath, sExample);
2125
2126 GetTempPathW(ARRAY_SIZE(sExample2Path), sExample2Path);
2127 lstrcatW(sExample2Path, sExample2);
2128
2129 lstrcpyW(sSubFolderPath, sExamplePath);
2130 lstrcatW(sSubFolderPath, sBackslash);
2131 lstrcatW(sSubFolderPath, sSubFolder);
2132
2133 lstrcpyW(sSubFolder2Path, sExample2Path);
2134 lstrcatW(sSubFolder2Path, sBackslash);
2135 lstrcatW(sSubFolder2Path, sSubFolder);
2136
2138
2139 hr = CoCreateInstance(&CLSID_KnownFolderManager, NULL, CLSCTX_INPROC_SERVER,
2140 &IID_IKnownFolderManager, (LPVOID*)&mgr);
2141 if(hr == REGDB_E_CLASSNOTREG)
2142 win_skip("IKnownFolderManager unavailable\n");
2143 else
2144 {
2145 IUnknown *unk;
2146
2147 ok(hr == S_OK, "failed to create KnownFolderManager instance: 0x%08x\n", hr);
2148
2149 hr = IKnownFolderManager_QueryInterface(mgr, &IID_IMarshal, (void**)&unk);
2150 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
2151
2152 hr = IKnownFolderManager_FolderIdFromCsidl(mgr, CSIDL_WINDOWS, &folderId);
2153 ok(hr == S_OK, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr);
2154 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2155
2156 hr = IKnownFolderManager_FolderIdToCsidl(mgr, &FOLDERID_Windows, &csidl);
2157 ok(hr == S_OK, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr);
2158 ok(csidl == CSIDL_WINDOWS, "invalid CSIDL returned\n");
2159
2160 hr = IKnownFolderManager_GetFolder(mgr, &FOLDERID_Windows, &folder);
2161 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2162 if(SUCCEEDED(hr))
2163 {
2164 hr = IKnownFolder_QueryInterface(folder, &IID_IMarshal, (void**)&unk);
2165 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
2166
2167 hr = IKnownFolder_GetCategory(folder, &cat);
2168 ok(hr == S_OK, "failed to get folder category: 0x%08x\n", hr);
2169 ok(cat==KF_CATEGORY_FIXED, "invalid folder category: %d\n", cat);
2170
2171 hr = IKnownFolder_GetId(folder, &folderId);
2172 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2173 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2174
2175 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2176 ok(hr == S_OK, "failed to get path from known folder: 0x%08x\n", hr);
2177 ok(lstrcmpiW(sWinDir, folderPath)==0, "invalid path returned: \"%s\", expected: \"%s\"\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sWinDir));
2178 CoTaskMemFree(folderPath);
2179
2180 hr = IKnownFolder_GetRedirectionCapabilities(folder, &redirectionCapabilities);
2181 ok(hr == S_OK, "failed to get redirection capabilities: 0x%08x\n", hr);
2182 todo_wine
2183 ok(redirectionCapabilities==0, "invalid redirection capabilities returned: %d\n", redirectionCapabilities);
2184
2185 hr = IKnownFolder_SetPath(folder, 0, sWinDir);
2186 todo_wine
2187 ok(hr == E_INVALIDARG, "unexpected value from SetPath: 0x%08x\n", hr);
2188
2189 hr = IKnownFolder_GetFolderDefinition(folder, &kfDefinition);
2190 ok(hr == S_OK, "failed to get folder definition: 0x%08x\n", hr);
2191 if(SUCCEEDED(hr))
2192 {
2193 ok(kfDefinition.category==KF_CATEGORY_FIXED, "invalid folder category: 0x%08x\n", kfDefinition.category);
2194 ok(lstrcmpW(kfDefinition.pszName, sWindows)==0, "invalid folder name: %s\n", wine_dbgstr_w(kfDefinition.pszName));
2195 ok(kfDefinition.dwAttributes==0, "invalid folder attributes: %d\n", kfDefinition.dwAttributes);
2196 FreeKnownFolderDefinitionFields(&kfDefinition);
2197 }
2198
2199 hr = IKnownFolder_Release(folder);
2200 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2201 }
2202
2203 hr = IKnownFolderManager_GetFolderByName(mgr, sWindows, &folder);
2204 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2205 if(SUCCEEDED(hr))
2206 {
2207 hr = IKnownFolder_GetId(folder, &folderId);
2208 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2209 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2210
2211 hr = IKnownFolder_Release(folder);
2212 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2213 }
2214
2215 hr = IKnownFolderManager_GetFolderByName(mgr, sWindows2, &folder);
2216 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2217 if(SUCCEEDED(hr))
2218 {
2219 hr = IKnownFolder_GetId(folder, &folderId);
2220 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2221 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2222
2223 hr = IKnownFolder_Release(folder);
2224 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2225 }
2226
2227 folder = (IKnownFolder *)0xdeadbeef;
2228 hr = IKnownFolderManager_GetFolderByName(mgr, sNoSuch, &folder);
2229 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
2230 ok(folder == NULL, "got %p\n", folder);
2231
2232 for(i=0; i < ARRAY_SIZE(known_folder_found); ++i)
2234
2235 hr = IKnownFolderManager_GetFolderIds(mgr, &folders, &nCount);
2236 ok(hr == S_OK, "failed to get known folders: 0x%08x\n", hr);
2237 for(i=0;i<nCount;++i)
2238 check_known_folder(mgr, &folders[i]);
2239
2240 for(i=0; i < ARRAY_SIZE(known_folder_found); ++i)
2241 if(!known_folder_found[i])
2242 trace("Known folder %s not found on current platform\n", known_folders[i].sFolderId);
2243
2244 CoTaskMemFree(folders);
2245
2246 /* test of registering new known folders */
2247 bRes = CreateDirectoryW(sExamplePath, NULL);
2248 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sExamplePath));
2249 bRes = CreateDirectoryW(sExample2Path, NULL);
2250 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sExample2Path));
2251 bRes = CreateDirectoryW(sSubFolderPath, NULL);
2252 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolderPath));
2253
2254 ZeroMemory(&kfDefinition, sizeof(kfDefinition));
2255 kfDefinition.category = KF_CATEGORY_PERUSER;
2256 kfDefinition.pszName = CoTaskMemAlloc(sizeof(sExample));
2257 lstrcpyW(kfDefinition.pszName, sExample);
2258 kfDefinition.pszDescription = CoTaskMemAlloc(sizeof(sExample));
2259 lstrcpyW(kfDefinition.pszDescription, sExample);
2260 kfDefinition.pszRelativePath = CoTaskMemAlloc(sizeof(sExamplePath));
2261 lstrcpyW(kfDefinition.pszRelativePath, sExamplePath);
2262
2263 hr = IKnownFolderManager_RegisterFolder(mgr, &newFolderId, &kfDefinition);
2265 win_skip("No permissions required to register custom known folder\n");
2266 else
2267 {
2268 ok(hr == S_OK, "failed to register known folder: 0x%08x\n", hr);
2269 if(SUCCEEDED(hr))
2270 {
2271 hr = IKnownFolderManager_GetFolder(mgr, &newFolderId, &folder);
2272 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2273 if(SUCCEEDED(hr))
2274 {
2275 hr = IKnownFolder_GetCategory(folder, &cat);
2276 ok(hr == S_OK, "failed to get folder category: hr=0x%0x\n", hr);
2277 ok(cat == KF_CATEGORY_PERUSER, "invalid category returned: %d, while %d (KF_CATEGORY_PERUSER) expected\n", cat, KF_CATEGORY_PERUSER);
2278
2279 hr = IKnownFolder_GetId(folder, &folderId);
2280 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2281 ok(IsEqualGUID(&folderId, &newFolderId)==TRUE, "invalid KNOWNFOLDERID returned\n");
2282
2283 /* current path should be Temp\Example */
2284 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2285 ok(hr == S_OK, "failed to get path from known folder: 0x%08x\n", hr);
2286 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2287 CoTaskMemFree(folderPath);
2288
2289 /* register sub-folder and mark it as child of Example folder */
2290 ZeroMemory(&kfSubDefinition, sizeof(kfSubDefinition));
2291 kfSubDefinition.category = KF_CATEGORY_PERUSER;
2292 kfSubDefinition.pszName = CoTaskMemAlloc(sizeof(sSubFolder));
2293 lstrcpyW(kfSubDefinition.pszName, sSubFolder);
2294 kfSubDefinition.pszDescription = CoTaskMemAlloc(sizeof(sSubFolder));
2295 lstrcpyW(kfSubDefinition.pszDescription, sSubFolder);
2296 kfSubDefinition.pszRelativePath = CoTaskMemAlloc(sizeof(sSubFolder));
2297 lstrcpyW(kfSubDefinition.pszRelativePath, sSubFolder);
2298 kfSubDefinition.fidParent = newFolderId;
2299
2300 hr = IKnownFolderManager_RegisterFolder(mgr, &subFolderId, &kfSubDefinition);
2301 ok(hr == S_OK, "failed to register known folder: 0x%08x\n", hr);
2302 if(SUCCEEDED(hr))
2303 {
2304
2305 hr = IKnownFolderManager_GetFolder(mgr, &subFolderId, &subFolder);
2306 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2307 if(SUCCEEDED(hr))
2308 {
2309 /* check sub folder path */
2310 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2311 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2312 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2313 CoTaskMemFree(folderPath);
2314
2315
2316 /* try to redirect Example to Temp\Example2 */
2317 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, 0, sExample2Path, 0, NULL, &errorMsg);
2318 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2319
2320 /* verify */
2321 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2322 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2323 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2324 CoTaskMemFree(folderPath);
2325
2326 /* verify sub folder - it should fail now, as we redirected its parent folder, but we have no sub folder in new location */
2327 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2328 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "unexpected value from GetPath(): 0x%08x\n", hr);
2329 ok(folderPath==NULL, "invalid known folder path retrieved: \"%s\" when NULL pointer was expected\n", wine_dbgstr_w(folderPath));
2330 CoTaskMemFree(folderPath);
2331
2332
2333 /* set Example path to original. Using SetPath() is valid here, as it also uses redirection internally */
2334 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2335 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2336
2337 /* verify */
2338 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2339 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2340 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2341 CoTaskMemFree(folderPath);
2342
2343
2344 /* create sub folder in Temp\Example2 */
2345 bRes = CreateDirectoryW(sSubFolder2Path, NULL);
2346 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path));
2347
2348 /* again perform that same redirection */
2349 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, 0, sExample2Path, 0, NULL, &errorMsg);
2350 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2351
2352 /* verify sub folder. It should succeed now, as the required sub folder exists */
2353 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2354 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2355 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2356 CoTaskMemFree(folderPath);
2357
2358 /* remove newly created directory */
2359 RemoveDirectoryW(sSubFolder2Path);
2360
2361 /* verify subfolder. It still succeeds, so Windows does not check folder presence each time */
2362 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2363 todo_wine
2364 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2365 todo_wine
2366 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2367 CoTaskMemFree(folderPath);
2368
2369
2370 /* set Example path to original */
2371 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2372 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2373
2374 /* verify */
2375 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2376 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2377 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2378 CoTaskMemFree(folderPath);
2379
2380 /* verify sub folder */
2381 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2382 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2383 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2384 CoTaskMemFree(folderPath);
2385
2386
2387 /* create sub folder in Temp\Example2 */
2388 bRes = CreateDirectoryW(sSubFolder2Path, NULL);
2389 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path));
2390
2391 /* do that same redirection, but try to exclude sub-folder */
2392 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, 0, sExample2Path, 1, &subFolderId, &errorMsg);
2393 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2394
2395 /* verify */
2396 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2397 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2398 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2399 CoTaskMemFree(folderPath);
2400
2401 /* verify sub folder. Unexpectedly, this path was also changed. So, exclusion seems to be ignored (Windows bug)? This test however will let us know, if this behavior is changed */
2402 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2403 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2404 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2405 CoTaskMemFree(folderPath);
2406
2407 /* remove newly created directory */
2408 RemoveDirectoryW(sSubFolder2Path);
2409
2410
2411 /* set Example path to original */
2412 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2413 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2414
2415 /* verify */
2416 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2417 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2418 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2419 CoTaskMemFree(folderPath);
2420
2421 /* verify sub folder */
2422 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2423 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2424 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2425 CoTaskMemFree(folderPath);
2426
2427
2428 /* do that same redirection again, but set it to copy content. It should also copy the sub folder, so checking it would succeed now */
2429 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, KF_REDIRECT_COPY_CONTENTS, sExample2Path, 0, NULL, &errorMsg);
2430 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2431
2432 /* verify */
2433 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2434 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2435 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2436 CoTaskMemFree(folderPath);
2437
2438 /* verify sub folder */
2439 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2440 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2441 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2442 CoTaskMemFree(folderPath);
2443
2444 /* remove copied directory */
2445 RemoveDirectoryW(sSubFolder2Path);
2446
2447
2448 /* set Example path to original */
2449 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2450 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2451
2452 /* verify */
2453 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2454 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2455 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2456 CoTaskMemFree(folderPath);
2457
2458 /* verify sub folder */
2459 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2460 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2461 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2462 CoTaskMemFree(folderPath);
2463
2464
2465 /* redirect again, set it to copy content and remove originals */
2466 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, KF_REDIRECT_COPY_CONTENTS | KF_REDIRECT_DEL_SOURCE_CONTENTS, sExample2Path, 0, NULL, &errorMsg);
2467 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2468
2469 /* verify */
2470 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2471 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2472 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2473 CoTaskMemFree(folderPath);
2474
2475 /* verify sub folder */
2476 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2477 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2478 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2479 CoTaskMemFree(folderPath);
2480
2481 /* check if original directory was really removed */
2482 dwAttributes = GetFileAttributesW(sExamplePath);
2483 ok(dwAttributes==INVALID_FILE_ATTRIBUTES, "directory should not exist, but has attributes: 0x%08x\n", dwAttributes );
2484
2485
2486 /* redirect (with copy) to original path */
2487 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, KF_REDIRECT_COPY_CONTENTS, sExamplePath, 0, NULL, &errorMsg);
2488 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2489
2490 /* verify */
2491 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2492 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2493 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2494 CoTaskMemFree(folderPath);
2495
2496 /* verify sub folder */
2497 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2498 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2499 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2500 CoTaskMemFree(folderPath);
2501
2502 /* check shell utility functions */
2503 if(!pSHGetKnownFolderPath || !pSHSetKnownFolderPath)
2504 todo_wine
2505 win_skip("cannot get SHGet/SetKnownFolderPath routines\n");
2506 else
2507 {
2508 /* try to get current known folder path */
2509 hr = pSHGetKnownFolderPath(&newFolderId, 0, NULL, &folderPath);
2510 todo_wine
2511 ok(hr==S_OK, "cannot get known folder path: hr=0x%0x\n", hr);
2512 todo_wine
2513 ok(lstrcmpW(folderPath, sExamplePath)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath));
2514
2515 /* set it to new value */
2516 hr = pSHSetKnownFolderPath(&newFolderId, 0, NULL, sExample2Path);
2517 todo_wine
2518 ok(hr==S_OK, "cannot set known folder path: hr=0x%0x\n", hr);
2519
2520 /* check if it changed */
2521 hr = pSHGetKnownFolderPath(&newFolderId, 0, NULL, &folderPath);
2522 todo_wine
2523 ok(hr==S_OK, "cannot get known folder path: hr=0x%0x\n", hr);
2524 todo_wine
2525 ok(lstrcmpW(folderPath, sExample2Path)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath));
2526
2527 /* set it back */
2528 hr = pSHSetKnownFolderPath(&newFolderId, 0, NULL, sExamplePath);
2529 todo_wine
2530 ok(hr==S_OK, "cannot set known folder path: hr=0x%0x\n", hr);
2531 }
2532
2533 IKnownFolder_Release(subFolder);
2534 }
2535
2536 hr = IKnownFolderManager_UnregisterFolder(mgr, &subFolderId);
2537 ok(hr == S_OK, "failed to unregister folder: 0x%08x\n", hr);
2538 }
2539
2540 FreeKnownFolderDefinitionFields(&kfSubDefinition);
2541
2542 hr = IKnownFolder_Release(folder);
2543 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2544
2545 /* update the folder */
2546 CoTaskMemFree(kfDefinition.pszName);
2547 kfDefinition.pszName = CoTaskMemAlloc(sizeof(sExample2));
2548 lstrcpyW(kfDefinition.pszName, sExample2);
2549 hr = IKnownFolderManager_RegisterFolder(mgr, &newFolderId, &kfDefinition);
2550 ok(hr == S_OK, "failed to re-register known folder: 0x%08x\n", hr);
2551
2552 hr = IKnownFolderManager_GetFolder(mgr, &newFolderId, &folder);
2553 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2554
2555 hr = IKnownFolder_GetFolderDefinition(folder, &kfSubDefinition);
2556 ok(hr == S_OK, "failed to get folder definition: 0x%08x\n", hr);
2557 ok(!memcmp(kfDefinition.pszName, kfSubDefinition.pszName, sizeof(sExample2)),
2558 "Got wrong updated name: %s\n", wine_dbgstr_w(kfSubDefinition.pszName));
2559
2560 FreeKnownFolderDefinitionFields(&kfSubDefinition);
2561
2562 hr = IKnownFolder_Release(folder);
2563 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2564 }
2565
2566 hr = IKnownFolderManager_UnregisterFolder(mgr, &newFolderId);
2567 ok(hr == S_OK, "failed to unregister folder: 0x%08x\n", hr);
2568 }
2569 }
2570 FreeKnownFolderDefinitionFields(&kfDefinition);
2571
2572 RemoveDirectoryW(sSubFolder2Path);
2573 RemoveDirectoryW(sSubFolderPath);
2574 RemoveDirectoryW(sExamplePath);
2575 RemoveDirectoryW(sExample2Path);
2576
2577 hr = IKnownFolderManager_Release(mgr);
2578 ok(hr == S_OK, "failed to release KnownFolderManager instance: 0x%08x\n", hr);
2579 }
2581}
#define E_INVALIDARG
Definition: ddrawi.h:101
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:700
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:1999
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2271
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
unsigned int UINT
Definition: sysinfo.c:13
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define ZeroMemory
Definition: minwinbase.h:31
static void check_known_folder(IKnownFolderManager *mgr, KNOWNFOLDERID *folderId)
Definition: shellpath.c:1991
pointer_default(unique)] interface IFileDialogCustomize enum tagKF_REDIRECTION_CAPABILITIES KF_REDIRECTION_CAPABILITIES
uint16_t * LPWSTR
Definition: typedefs.h:56
DWORD dwAttributes
Definition: vdmdbg.h:34
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:3801
#define E_NOINTERFACE
Definition: winerror.h:3479

Referenced by START_TEST().

◆ test_NonExistentPath()

static void test_NonExistentPath ( void  )
static

Definition at line 1797 of file shellpath.c.

1798{
1799 static const char userShellFolders[] =
1800 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
1801 char originalPath[MAX_PATH], modifiedPath[MAX_PATH];
1802 HKEY key;
1803
1804 if (!pSHGetFolderPathA) return;
1805 if (!pSHGetFolderLocation) return;
1806 if (!pSHGetSpecialFolderPathA) return;
1807 if (!pSHGetSpecialFolderLocation) return;
1808 if (!pSHFileOperationA) return;
1809 if (shellVersion.dwMajorVersion < 5) return;
1810
1811 if (!RegOpenKeyExA(HKEY_CURRENT_USER, userShellFolders, 0, KEY_ALL_ACCESS,
1812 &key))
1813 {
1814 DWORD len, type;
1815
1816 len = sizeof(originalPath);
1817 if (!RegQueryValueExA(key, "Favorites", NULL, &type,
1818 (LPBYTE)&originalPath, &len))
1819 {
1820 size_t len = strlen(originalPath);
1821
1822 memcpy(modifiedPath, originalPath, len);
1823 modifiedPath[len++] = '2';
1824 modifiedPath[len++] = '\0';
1825 trace("Changing CSIDL_FAVORITES to %s\n", modifiedPath);
1826 if (!RegSetValueExA(key, "Favorites", 0, type,
1827 (LPBYTE)modifiedPath, len))
1828 {
1829 char buffer[MAX_PATH+20];
1832
1833 sprintf(buffer, "%s tests/shellpath.c 1", selfname);
1834 memset(&startup, 0, sizeof(startup));
1835 startup.cb = sizeof(startup);
1836 startup.dwFlags = STARTF_USESHOWWINDOW;
1837 startup.wShowWindow = SW_SHOWNORMAL;
1839 &startup, &info);
1841
1842 /* restore original values: */
1843 trace("Restoring CSIDL_FAVORITES to %s\n", originalPath);
1844 RegSetValueExA(key, "Favorites", 0, type, (LPBYTE) originalPath,
1845 strlen(originalPath) + 1);
1847
1848 sprintf(buffer, "%s tests/shellpath.c 2", selfname);
1849 memset(&startup, 0, sizeof(startup));
1850 startup.cb = sizeof(startup);
1851 startup.dwFlags = STARTF_USESHOWWINDOW;
1852 startup.wShowWindow = SW_SHOWNORMAL;
1854 &startup, &info);
1855 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0,
1856 "child process termination\n");
1857 }
1858 }
1859 else skip("RegQueryValueExA(key, Favorites, ...) failed\n");
1860 if (key)
1862 }
1863 else skip("RegOpenKeyExA(HKEY_CURRENT_USER, %s, ...) failed\n", userShellFolders);
1864}
static void startup(void)
#define skip(...)
Definition: atltest.h:64
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2951
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
Definition: process.c:686
#define L(x)
Definition: resources.c:13
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
void winetest_wait_child_process(HANDLE process)
Definition: copy.c:22
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned char * LPBYTE
Definition: typedefs.h:53
#define STARTF_USESHOWWINDOW
Definition: winbase.h:468
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SW_SHOWNORMAL
Definition: winuser.h:781

Referenced by START_TEST().

◆ test_parameters()

static void test_parameters ( void  )
static

Definition at line 1337 of file shellpath.c.

1338{
1339 LPITEMIDLIST pidl = NULL;
1340 char path[MAX_PATH];
1341 HRESULT hr;
1342
1343 if (pSHGetFolderLocation)
1344 {
1345 /* check a bogus CSIDL: */
1346 pidl = NULL;
1347 hr = pSHGetFolderLocation(NULL, 0xeeee, NULL, 0, &pidl);
1348 ok(hr == E_INVALIDARG, "got 0x%08x, expected E_INVALIDARG\n", hr);
1349 if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
1350
1351 /* check a bogus user token: */
1352 pidl = NULL;
1353 hr = pSHGetFolderLocation(NULL, CSIDL_FAVORITES, (HANDLE)2, 0, &pidl);
1354 ok(hr == E_FAIL || hr == E_HANDLE, "got 0x%08x, expected E_FAIL or E_HANDLE\n", hr);
1355 if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
1356
1357 /* a NULL pidl pointer crashes, so don't test it */
1358 }
1359
1360 if (pSHGetSpecialFolderLocation)
1361 {
1362 if (0)
1363 /* crashes */
1365
1366 hr = pSHGetSpecialFolderLocation(NULL, 0xeeee, &pidl);
1367 ok(hr == E_INVALIDARG, "got returned 0x%08x\n", hr);
1368 }
1369
1370 if (pSHGetFolderPathA)
1371 {
1372 /* expect 2's a bogus handle, especially since we didn't open it */
1373 hr = pSHGetFolderPathA(NULL, CSIDL_DESKTOP, (HANDLE)2, SHGFP_TYPE_DEFAULT, path);
1374 ok(hr == E_FAIL || hr == E_HANDLE || /* Vista and 2k8 */
1375 broken(hr == S_OK), /* W2k and Me */ "got 0x%08x, expected E_FAIL\n", hr);
1376
1377 hr = pSHGetFolderPathA(NULL, 0xeeee, NULL, SHGFP_TYPE_DEFAULT, path);
1378 ok(hr == E_INVALIDARG, "got 0x%08x, expected E_INVALIDARG\n", hr);
1379 }
1380
1381 if (pSHGetSpecialFolderPathA)
1382 {
1383 BOOL ret;
1384
1385 if (0)
1386 pSHGetSpecialFolderPathA(NULL, NULL, CSIDL_BITBUCKET, FALSE);
1387
1388 /* odd but true: calling with a NULL path still succeeds if it's a real
1389 * dir (on some windows platform). on winME it generates exception.
1390 */
1391 ret = pSHGetSpecialFolderPathA(NULL, path, CSIDL_PROGRAMS, FALSE);
1392 ok(ret, "got %d\n", ret);
1393
1394 ret = pSHGetSpecialFolderPathA(NULL, path, 0xeeee, FALSE);
1395 ok(!ret, "got %d\n", ret);
1396 }
1397}
#define broken(x)
Definition: atltest.h:178
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2167
#define E_HANDLE
Definition: winerror.h:4117

Referenced by START_TEST().

◆ test_PathYetAnotherMakeUniqueName()

static void test_PathYetAnotherMakeUniqueName ( void  )
static

Definition at line 2734 of file shellpath.c.

2735{
2736 static const WCHAR shortW[] = {'f','i','l','e','.','t','s','t',0};
2737 static const WCHAR short2W[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
2738 static const WCHAR tmpW[] = {'t','m','p',0};
2739 static const WCHAR longW[] = {'n','a','m','e',0};
2740 static const WCHAR long2W[] = {'n','a','m','e',' ','(','2',')',0};
2742 HANDLE file;
2743 BOOL ret;
2744
2745 if (!pPathYetAnotherMakeUniqueName)
2746 {
2747 win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
2748 return;
2749 }
2750
2751if (0)
2752{
2753 /* crashes on Windows */
2754 ret = pPathYetAnotherMakeUniqueName(NULL, NULL, NULL, NULL);
2755 ok(!ret, "got %d\n", ret);
2756
2757 ret = pPathYetAnotherMakeUniqueName(nameW, NULL, NULL, NULL);
2758 ok(!ret, "got %d\n", ret);
2759}
2760
2762
2763 /* Using short name only first */
2764 nameW[0] = 0;
2765 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
2766 ok(ret, "got %d\n", ret);
2767 lstrcpyW(buffW, pathW);
2768 lstrcatW(buffW, shortW);
2769 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2770
2771 /* now create a file with this name and get next name */
2773 ok(file != NULL, "got %p\n", file);
2774
2775 nameW[0] = 0;
2776 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
2777 ok(ret, "got %d\n", ret);
2778 lstrcpyW(buffW, pathW);
2779 lstrcatW(buffW, short2W);
2780 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2781
2783
2784 /* Using short and long */
2785 nameW[0] = 0;
2786 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
2787 ok(ret, "got %d\n", ret);
2788 lstrcpyW(buffW, pathW);
2789 lstrcatW(buffW, longW);
2790 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2791
2793 ok(file != NULL, "got %p\n", file);
2794
2795 nameW[0] = 0;
2796 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
2797 ok(ret, "got %d\n", ret);
2798 lstrcpyW(buffW, pathW);
2799 lstrcatW(buffW, long2W);
2800 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2801
2803
2804 /* Using long only */
2805 nameW[0] = 0;
2806 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, NULL, longW);
2807 ok(ret, "got %d\n", ret);
2808 lstrcpyW(buffW, pathW);
2809 lstrcatW(buffW, longW);
2810 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2811}
static const WCHAR nameW[]
Definition: main.c:49
#define CloseHandle
Definition: compat.h:739
#define CreateFileW
Definition: compat.h:741
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_FLAG_DELETE_ON_CLOSE
Definition: disk.h:42
static const WCHAR pathW[]
Definition: path.c:2368
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: fci.c:127

Referenced by START_TEST().

◆ test_PidlTypes()

static void test_PidlTypes ( void  )
static

Definition at line 1587 of file shellpath.c.

1588{
1589 /* Desktop */
1592
1595}
static void test_SHGetSpecialFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1467
static void test_SHGetFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1455
static const struct shellExpectedValues optionalShellValues[]
Definition: shellpath.c:142
static void test_ShellValues(const struct shellExpectedValues testEntries[], int numEntries, BOOL optional)
Definition: shellpath.c:1482
static const struct shellExpectedValues requiredShellValues[]
Definition: shellpath.c:118

Referenced by START_TEST().

◆ test_ShellValues()

static void test_ShellValues ( const struct shellExpectedValues  testEntries[],
int  numEntries,
BOOL  optional 
)
static

Definition at line 1482 of file shellpath.c.

1484{
1485 int i;
1486
1487 for (i = 0; i < numEntries; i++)
1488 {
1489 BYTE type;
1490 int j;
1491 BOOL foundTypeMatch = FALSE;
1492
1493 if (pSHGetFolderLocation)
1494 {
1495 type = testSHGetFolderLocation(testEntries[i].folder);
1496 for (j = 0; !foundTypeMatch && j < testEntries[i].numTypes; j++)
1497 if (testEntries[i].types[j] == type)
1498 foundTypeMatch = TRUE;
1499 ok(foundTypeMatch || optional || broken(type == 0xff) /* Win9x */,
1500 "%s has unexpected type %d (0x%02x)\n",
1501 getFolderName(testEntries[i].folder), type, type);
1502 }
1504 for (j = 0, foundTypeMatch = FALSE; !foundTypeMatch &&
1505 j < testEntries[i].numTypes; j++)
1506 if (testEntries[i].types[j] == type)
1507 foundTypeMatch = TRUE;
1508 ok(foundTypeMatch || optional || broken(type == 0xff) /* Win9x */,
1509 "%s has unexpected type %d (0x%02x)\n",
1510 getFolderName(testEntries[i].folder), type, type);
1511 switch (type)
1512 {
1513 case PT_FOLDER:
1514 case PT_DRIVE:
1515 case PT_DRIVE2:
1516 case PT_IESPECIAL2:
1517 test_SHGetFolderPath(optional, testEntries[i].folder);
1519 break;
1520 }
1521 }
1522}
@ optional
Definition: SystemMenu.c:34
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define PT_FOLDER
Definition: shellpath.c:63
static BYTE testSHGetFolderLocation(int folder)
Definition: shellpath.c:1400
#define PT_DRIVE
Definition: shellpath.c:54
#define PT_DRIVE2
Definition: shellpath.c:57
static BYTE testSHGetSpecialFolderLocation(int folder)
Definition: shellpath.c:1428
#define PT_IESPECIAL2
Definition: shellpath.c:76
Definition: cmds.c:130
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_PidlTypes().

◆ test_SHGetFolderPath()

static void test_SHGetFolderPath ( BOOL  optional,
int  folder 
)
static

Definition at line 1455 of file shellpath.c.

1456{
1457 char path[MAX_PATH];
1458 HRESULT hr;
1459
1460 if (!pSHGetFolderPathA) return;
1461
1462 hr = pSHGetFolderPathA(NULL, folder, NULL, SHGFP_TYPE_CURRENT, path);
1463 ok(hr == S_OK || optional,
1464 "SHGetFolderPathA(NULL, %s, NULL, SHGFP_TYPE_CURRENT, path) failed: 0x%08x\n", getFolderName(folder), hr);
1465}

Referenced by test_PidlTypes(), and test_ShellValues().

◆ test_SHGetFolderPathEx()

static void test_SHGetFolderPathEx ( void  )
static

Definition at line 1866 of file shellpath.c.

1867{
1869 unsigned int i;
1870 HRESULT hr;
1871 DWORD len;
1872
1873 if (!pSHGetKnownFolderPath || !pSHGetFolderPathEx)
1874 {
1875 win_skip("SHGetKnownFolderPath or SHGetFolderPathEx not available\n");
1876 return;
1877 }
1878
1879if (0) { /* crashes */
1880 hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, NULL);
1881 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1882}
1883 /* non-existent folder id */
1884 path = (void *)0xdeadbeef;
1885 hr = pSHGetKnownFolderPath(&IID_IOleObject, 0, NULL, &path);
1886 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
1887 ok(path == NULL, "got %p\n", path);
1888
1889 path = NULL;
1890 hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, KF_FLAG_DEFAULT_PATH, NULL, &path);
1891 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1892 ok(path != NULL, "expected path != NULL\n");
1894
1895 for (i = 0; i < ARRAY_SIZE(known_folders); ++i)
1896 {
1897 const KNOWNFOLDERID *folder_id = known_folders[i].folderId;
1898
1899 path = NULL;
1900 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_DEFAULT, NULL, &path);
1901 if (FAILED(hr))
1902 {
1903 ok(path == NULL, "expected path == NULL\n");
1904 continue;
1905 }
1906 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1907 ok(path != NULL, "expected path != NULL\n");
1908
1909 path2 = NULL;
1910 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_SIMPLE_IDLIST, NULL, &path2);
1911 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1912 ok(path2 != NULL, "expected path != NULL\n");
1913 ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1915
1916 path2 = NULL;
1917 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_DONT_UNEXPAND, NULL, &path2);
1918 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1919 ok(path2 != NULL, "expected path != NULL\n");
1920 ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1922
1923 path2 = NULL;
1924 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL, &path2);
1925 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1926 ok(path2 != NULL, "expected path != NULL\n");
1927 ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1929
1931 }
1932
1933 path = NULL;
1934 hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, &path);
1935 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1936 ok(path != NULL, "expected path != NULL\n");
1937
1938 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, MAX_PATH);
1939 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1940 ok(!lstrcmpiW(path, buffer), "expected equal paths\n");
1941 len = lstrlenW(buffer);
1943
1944 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, 0);
1945 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1946
1947if (0) { /* crashes */
1948 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, NULL, len + 1);
1949 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1950
1951 hr = pSHGetFolderPathEx(NULL, 0, NULL, buffer, MAX_PATH);
1952 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1953}
1954 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len);
1955 ok(hr == E_NOT_SUFFICIENT_BUFFER, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr);
1956
1957 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len + 1);
1958 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1959}
#define lstrlenW
Definition: compat.h:750
#define FAILED(hr)
Definition: intsafe.h:51
static const WCHAR path2[]
Definition: path.c:29
const GUID IID_IOleObject
@ KF_FLAG_SIMPLE_IDLIST
Definition: shlobj.h:99
@ KF_FLAG_DONT_UNEXPAND
Definition: shlobj.h:104
@ KF_FLAG_DEFAULT
Definition: shlobj.h:98
#define KF_FLAG_DEFAULT_PATH
Definition: shlobj.h:325
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437

Referenced by START_TEST().

◆ test_SHGetKnownFolderIDList()

static void test_SHGetKnownFolderIDList ( void  )
static

Definition at line 2813 of file shellpath.c.

2814{
2815 PIDLIST_ABSOLUTE pidl;
2816 HRESULT hr;
2817
2818 if (!pSHGetKnownFolderIDList)
2819 {
2820 win_skip("SHGetKnownFolderIDList is not available.\n");
2821 return;
2822 }
2823
2824 hr = pSHGetKnownFolderIDList(NULL, 0, NULL, NULL);
2825 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2826
2827if (0) { /* crashes on native */
2828 pidl = (void*)0xdeadbeef;
2829 hr = pSHGetKnownFolderIDList(NULL, 0, NULL, &pidl);
2830}
2831 /* not a known folder */
2832 pidl = (void*)0xdeadbeef;
2833 hr = pSHGetKnownFolderIDList(&IID_IUnknown, 0, NULL, &pidl);
2834 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
2835 ok(pidl == NULL, "got %p\n", pidl);
2836
2837 hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, NULL);
2838 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2839
2840 pidl = (void*)0xdeadbeef;
2841 hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, &pidl);
2842 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2843 ok(ILIsEmpty(pidl), "pidl should be empty.\n");
2844 ok(pidl->mkid.cb == 0, "get wrong value: %d\n", pidl->mkid.cb);
2845 ILFree(pidl);
2846
2847 pidl = (void*)0xdeadbeef;
2848 hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, KF_FLAG_NO_ALIAS, NULL, &pidl);
2849 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2850 todo_wine ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2851 todo_wine ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2852 ILFree(pidl);
2853
2854 pidl = (void*)0xdeadbeef;
2855 hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, 0, NULL, &pidl);
2856 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2857 ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2858 ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2859 ILFree(pidl);
2860
2861 pidl = (void*)0xdeadbeef;
2862 hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, KF_FLAG_NO_ALIAS, NULL, &pidl);
2863 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2864 ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2865 ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2866 ILFree(pidl);
2867}
const GUID IID_IUnknown
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
@ KF_FLAG_NO_ALIAS
Definition: shlobj.h:103
static BOOL ILIsEmpty(_In_opt_ PCUIDLIST_RELATIVE pidl)
Definition: shlobj.h:2536
WORD cb
Definition: shtypes.idl:27
SHITEMID mkid
Definition: shtypes.idl:34

Referenced by START_TEST().

◆ test_SHGetSpecialFolderPath()

static void test_SHGetSpecialFolderPath ( BOOL  optional,
int  folder 
)
static

Definition at line 1467 of file shellpath.c.

1468{
1469 char path[MAX_PATH];
1470 BOOL ret;
1471
1472 if (!pSHGetSpecialFolderPathA) return;
1473
1474 ret = pSHGetSpecialFolderPathA(NULL, path, folder, FALSE);
1476 printf("%s: %s\n", getFolderName(folder), path);
1477 ok(ret || optional,
1478 "SHGetSpecialFolderPathA(NULL, path, %s, FALSE) failed\n",
1480}
#define printf
Definition: freeldr.h:103
int winetest_interactive

Referenced by test_PidlTypes(), and test_ShellValues().

◆ testSHGetFolderLocation()

static BYTE testSHGetFolderLocation ( int  folder)
static

Definition at line 1400 of file shellpath.c.

1401{
1402 LPITEMIDLIST pidl;
1403 HRESULT hr;
1404 BYTE ret = 0xff;
1405
1406 /* treat absence of function as success */
1407 if (!pSHGetFolderLocation) return TRUE;
1408
1409 pidl = NULL;
1410 hr = pSHGetFolderLocation(NULL, folder, NULL, 0, &pidl);
1411 if (hr == S_OK)
1412 {
1413 if (pidl)
1414 {
1415 LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1416
1417 ok(pidlLast != NULL, "%s: ILFindLastID failed\n",
1419 if (pidlLast)
1420 ret = pidlLast->mkid.abID[0];
1421 IMalloc_Free(pMalloc, pidl);
1422 }
1423 }
1424 return ret;
1425}

Referenced by test_ShellValues().

◆ testSHGetSpecialFolderLocation()

static BYTE testSHGetSpecialFolderLocation ( int  folder)
static

Definition at line 1428 of file shellpath.c.

1429{
1430 LPITEMIDLIST pidl;
1431 HRESULT hr;
1432 BYTE ret = 0xff;
1433
1434 /* treat absence of function as success */
1435 if (!pSHGetSpecialFolderLocation) return TRUE;
1436
1437 pidl = NULL;
1438 hr = pSHGetSpecialFolderLocation(NULL, folder, &pidl);
1439 if (hr == S_OK)
1440 {
1441 if (pidl)
1442 {
1443 LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1444
1445 ok(pidlLast != NULL,
1446 "%s: ILFindLastID failed\n", getFolderName(folder));
1447 if (pidlLast)
1448 ret = pidlLast->mkid.abID[0];
1449 IMalloc_Free(pMalloc, pidl);
1450 }
1451 }
1452 return ret;
1453}

Referenced by test_ShellValues().

◆ testSystemDir()

static void testSystemDir ( void  )
static

Definition at line 1675 of file shellpath.c.

1676{
1677 char systemShellPath[MAX_PATH], systemDir[MAX_PATH], systemDirx86[MAX_PATH];
1678
1679 if (!pSHGetSpecialFolderPathA) return;
1680
1681 GetSystemDirectoryA(systemDir, sizeof(systemDir));
1682 myPathRemoveBackslashA(systemDir);
1683 if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEM, FALSE))
1684 {
1685 myPathRemoveBackslashA(systemShellPath);
1686 ok(!lstrcmpiA(systemDir, systemShellPath),
1687 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1688 systemDir, systemShellPath);
1689 }
1690
1691 if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDirx86, sizeof(systemDirx86)))
1692 GetSystemDirectoryA(systemDirx86, sizeof(systemDirx86));
1693 myPathRemoveBackslashA(systemDirx86);
1694 if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE))
1695 {
1696 myPathRemoveBackslashA(systemShellPath);
1697 ok(!lstrcmpiA(systemDirx86, systemShellPath) || broken(!lstrcmpiA(systemDir, systemShellPath)),
1698 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1699 systemDir, systemShellPath);
1700 }
1701}
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2202
static LPSTR myPathRemoveBackslashA(LPSTR lpszPath)
Definition: shellpath.c:1637

Referenced by START_TEST().

◆ testWinDir()

static void testWinDir ( void  )
static

Definition at line 1654 of file shellpath.c.

1655{
1656 char windowsShellPath[MAX_PATH], windowsDir[MAX_PATH] = { 0 };
1657
1658 if (!pSHGetSpecialFolderPathA) return;
1659
1660 if (pSHGetSpecialFolderPathA(NULL, windowsShellPath, CSIDL_WINDOWS, FALSE))
1661 {
1662 myPathRemoveBackslashA(windowsShellPath);
1663 GetWindowsDirectoryA(windowsDir, sizeof(windowsDir));
1664 myPathRemoveBackslashA(windowsDir);
1665 ok(!lstrcmpiA(windowsDir, windowsShellPath),
1666 "GetWindowsDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1667 windowsDir, windowsShellPath);
1668 }
1669}
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2256

Referenced by START_TEST().

◆ UINT()

static UINT ( WINAPI pGetSystemWow64DirectoryA)
static

Variable Documentation

◆ _FOLDERID_CredentialManager

const GUID _FOLDERID_CredentialManager = {0x915221FB, 0x9EFE, 0x4BDA, {0x8F, 0xD7, 0xF7, 0x8D, 0xCA, 0x77, 0x4F, 0x87} }
static

Definition at line 317 of file shellpath.c.

◆ _FOLDERID_CryptoKeys

const GUID _FOLDERID_CryptoKeys = {0xB88F4DAA, 0xE7BD, 0x49A9, {0xB7, 0x4D, 0x02, 0x88, 0x5A, 0x5D, 0xC7, 0x65} }
static

Definition at line 314 of file shellpath.c.

◆ _FOLDERID_DpapiKeys

const GUID _FOLDERID_DpapiKeys = {0x10C07CD0, 0xEF91, 0x4567, {0xB8, 0x50, 0x44, 0x8B, 0x77, 0xCB, 0x37, 0xF9} }
static

Definition at line 315 of file shellpath.c.

◆ _FOLDERID_SystemCertificates

const GUID _FOLDERID_SystemCertificates = {0x54EED2E0, 0xE7CA, 0x4FDB, {0x91, 0x48, 0x0F, 0x42, 0x47, 0x29, 0x1C, 0xFA} }
static

Definition at line 316 of file shellpath.c.

◆ base

char base[MAX_PATH]
static

Definition at line 1706 of file shellpath.c.

◆ BOOL

LPITEMIDLIST *static BOOL

Definition at line 91 of file shellpath.c.

◆ CLSID_CommonDocuments

GUID CLSID_CommonDocuments = { 0x0000000c, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x1a } }
static

Definition at line 79 of file shellpath.c.

Referenced by test_GUIDs().

◆ controlPanelType

const BYTE controlPanelType[] = { PT_SHELLEXT, PT_GUID, PT_CPL }
static

Definition at line 106 of file shellpath.c.

◆ DWORD

Definition at line 88 of file shellpath.c.

◆ favoritesType

const BYTE favoritesType[] = { PT_FOLDER, PT_FOLDERW, 0, PT_IESPECIAL2 }
static

Definition at line 108 of file shellpath.c.

◆ folderOrSpecialType

const BYTE folderOrSpecialType[] = { PT_FOLDER, PT_IESPECIAL2 }
static

Definition at line 109 of file shellpath.c.

◆ folderType

const BYTE folderType[] = { PT_FOLDER, PT_FOLDERW }
static

Definition at line 107 of file shellpath.c.

◆ guidType

const BYTE guidType[] = { PT_GUID }
static

Definition at line 105 of file shellpath.c.

◆ HANDLE

Definition at line 88 of file shellpath.c.

◆ ieSpecialType

const BYTE ieSpecialType[] = { PT_IESPECIAL2 }
static

Definition at line 114 of file shellpath.c.

◆ int

int

Definition at line 88 of file shellpath.c.

◆ known_folder_found

BOOL known_folder_found[ARRAY_SIZE(known_folders)]

Definition at line 1335 of file shellpath.c.

Referenced by check_known_folder(), and test_knownFolders().

◆ known_folders

const struct knownFolderDef known_folders[]
static

Definition at line 343 of file shellpath.c.

Referenced by check_known_folder(), test_knownFolders(), and test_SHGetFolderPathEx().

◆ LPSTR

Definition at line 88 of file shellpath.c.

◆ LPWSTR

Definition at line 99 of file shellpath.c.

◆ myARGC

int myARGC
static

Definition at line 1704 of file shellpath.c.

Referenced by init(), and START_TEST().

◆ myARGV

char** myARGV
static

Definition at line 1705 of file shellpath.c.

Referenced by init(), and START_TEST().

◆ optionalShellValues

const struct shellExpectedValues optionalShellValues[]
static

Definition at line 142 of file shellpath.c.

Referenced by test_PidlTypes().

◆ PCWSTR

Definition at line 100 of file shellpath.c.

◆ personalType

const BYTE personalType[]
static
Initial value:

Definition at line 110 of file shellpath.c.

◆ pMalloc

◆ printersType

const BYTE printersType[] = { PT_YAGUID, PT_SHELLEXT, 0x71 }
static

Definition at line 113 of file shellpath.c.

◆ PWSTR

PWSTR *static PWSTR

Definition at line 98 of file shellpath.c.

◆ requiredShellValues

const struct shellExpectedValues requiredShellValues[]
static

◆ selfname

char selfname[MAX_PATH]
static

Definition at line 1707 of file shellpath.c.

Referenced by init(), and test_NonExistentPath().

◆ shellExtType

const BYTE shellExtType[] = { PT_SHELLEXT }
static

Definition at line 115 of file shellpath.c.

◆ shellVersion

PIDLIST_ABSOLUTE* static DLLVERSIONINFO shellVersion = { 0 }
static

Definition at line 103 of file shellpath.c.

Referenced by loadShell32(), and test_NonExistentPath().

◆ UINT

Definition at line 96 of file shellpath.c.

◆ workgroupType

const BYTE workgroupType[] = { PT_WORKGRP }
static

Definition at line 116 of file shellpath.c.