ReactOS  0.4.14-dev-50-g13bb5e2
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);
GLenum func
Definition: glext.h:6028
#define GetProcAddress(x, y)
Definition: compat.h:410
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 1964 of file shellpath.c.

1965 {
1966  HRESULT hr;
1967  int csidl, expectedCsidl, ret;
1969  IKnownFolder *folder;
1970  WCHAR sName[1024];
1971  BOOL found = FALSE;
1972  unsigned int i;
1973 
1974  for (i = 0; i < ARRAY_SIZE(known_folders); ++i)
1975  {
1976  const struct knownFolderDef *known_folder = &known_folders[i];
1977 
1978  if(IsEqualGUID(known_folder->folderId, folderId))
1979  {
1981  found = TRUE;
1982  /* verify CSIDL */
1983  if(!(known_folder->csidl & NO_CSIDL))
1984  {
1985  /* mask off winetest flags */
1986  expectedCsidl = known_folder->csidl & 0xFFFF;
1987 
1988  hr = IKnownFolderManager_FolderIdToCsidl(mgr, folderId, &csidl);
1989  ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot retrieve CSIDL for folder %s\n", known_folder->sFolderId);
1990 
1991  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);
1992  }
1993 
1994  hr = IKnownFolderManager_GetFolder(mgr, folderId, &folder);
1995  ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot get known folder for %s\n", known_folder->sFolderId);
1996  if(SUCCEEDED(hr))
1997  {
1998  hr = IKnownFolder_GetFolderDefinition(folder, &kfd);
1999  ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot get known folder definition for %s\n", known_folder->sFolderId);
2000  if(SUCCEEDED(hr))
2001  {
2002  ret = MultiByteToWideChar(CP_ACP, 0, known_folder->sName, -1, sName, ARRAY_SIZE(sName));
2003  ok_(__FILE__, known_folder->line)(ret != 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder->sName);
2004 
2005  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));
2006 
2007  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);
2008 
2009  ok_(__FILE__, known_folder->line)(IsEqualGUID(known_folder->fidParents[0], &kfd.fidParent) ||
2010  IsEqualGUID(known_folder->fidParents[1], &kfd.fidParent),
2011  "invalid known folder parent for %s: %s retrieved\n",
2012  known_folder->sFolderId, wine_dbgstr_guid(&kfd.fidParent));
2013 
2014  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));
2015 
2016  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));
2017 
2018  ok_(__FILE__, known_folder->line)(known_folder->attributes == kfd.dwAttributes ||
2019  (known_folder->csidl & WINE_ATTRIBUTES_OPTIONAL && kfd.dwAttributes == 0),
2020  "invalid known folder attributes for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder->sFolderId, known_folder->attributes, kfd.dwAttributes);
2021 
2022  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);
2023 
2025  }
2026 
2027  IKnownFolder_Release(folder);
2028  }
2029 
2030  break;
2031  }
2032  }
2033 
2034  if(!found)
2035  {
2036  trace("unknown known folder found: %s\n", wine_dbgstr_guid(folderId));
2037 
2038  hr = IKnownFolderManager_GetFolder(mgr, folderId, &folder);
2039  ok(hr == S_OK, "cannot get known folder for %s\n", wine_dbgstr_guid(folderId));
2040  if(SUCCEEDED(hr))
2041  {
2042  hr = IKnownFolder_GetFolderDefinition(folder, &kfd);
2043  todo_wine
2044  ok(hr == S_OK, "cannot get known folder definition for %s\n", wine_dbgstr_guid(folderId));
2045  if(SUCCEEDED(hr))
2046  {
2047  trace(" category: %d\n", kfd.category);
2048  trace(" name: %s\n", wine_dbgstr_w(kfd.pszName));
2049  trace(" description: %s\n", wine_dbgstr_w(kfd.pszDescription));
2050  trace(" parent: %s\n", wine_dbgstr_guid(&kfd.fidParent));
2051  trace(" relative path: %s\n", wine_dbgstr_w(kfd.pszRelativePath));
2052  trace(" parsing name: %s\n", wine_dbgstr_w(kfd.pszParsingName));
2053  trace(" tooltip: %s\n", wine_dbgstr_w(kfd.pszTooltip));
2054  trace(" localized name: %s\n", wine_dbgstr_w(kfd.pszLocalizedName));
2055  trace(" icon: %s\n", wine_dbgstr_w(kfd.pszIcon));
2056  trace(" security: %s\n", wine_dbgstr_w(kfd.pszSecurity));
2057  trace(" attributes: 0x%08x\n", kfd.dwAttributes);
2058  trace(" flags: 0x%08x\n", kfd.kfdFlags);
2059  trace(" type: %s\n", wine_dbgstr_guid(&kfd.ftidType));
2061  }
2062 
2063  IKnownFolder_Release(folder);
2064  }
2065  }
2066 }
KF_DEFINITION_FLAGS kfdFlags
Definition: shobjidl.idl:3906
#define TRUE
Definition: types.h:120
Definition: fci.c:115
const char * sCsidl
Definition: shellpath.c:323
HRESULT hr
Definition: shlfolder.c:183
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
const DWORD attributes
Definition: shellpath.c:329
const char * wine_dbgstr_guid(const GUID *guid)
static BOOL is_in_strarray(const WCHAR *needle, const char *hay)
Definition: shellpath.c:1934
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
const int line
Definition: shellpath.c:331
unsigned int BOOL
Definition: ntddk_ex.h:94
struct CFFOLDER folder
Definition: fdi.c:110
const KF_DEFINITION_FLAGS definitionFlags
Definition: shellpath.c:330
const char * sName
Definition: shellpath.c:324
const char * sParsingName
Definition: shellpath.c:328
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const int csidl
Definition: shellpath.c:322
int ret
BOOL known_folder_found[ARRAY_SIZE(known_folders)]
Definition: shellpath.c:1311
#define todo_wine
Definition: test.h:154
#define NO_CSIDL
Definition: shellpath.c:308
const KF_CATEGORY category
Definition: shellpath.c:325
const KNOWNFOLDERID * fidParents[2]
Definition: shellpath.c:326
#define S_OK
Definition: intsafe.h:59
const char * sFolderId
Definition: shellpath.c:321
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define MultiByteToWideChar
Definition: compat.h:100
const KNOWNFOLDERID * folderId
Definition: shellpath.c:320
const char * sRelativePath
Definition: shellpath.c:327
#define WINE_ATTRIBUTES_OPTIONAL
Definition: shellpath.c:309
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define ok_(x1, x2)
Definition: atltest.h:61
static void FreeKnownFolderDefinitionFields(KNOWNFOLDER_DEFINITION *pKFD)") cpp_quote("
Definition: shobjidl.idl:4025
static const struct knownFolderDef known_folders[]
Definition: shellpath.c:343

Referenced by test_knownFolders().

◆ DEFINE_GUID() [1/3]

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

◆ 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 ( _CLSID_Documents  ,
0xA8CDFF1C  ,
0x4878  ,
0x43be  ,
0xB5  ,
0xFD  ,
0xF8  ,
0x09  ,
0x1C  ,
0x1C  ,
0x60  ,
0xD0   
)

◆ doChild()

static void doChild ( const char arg)
static

Definition at line 1693 of file shellpath.c.

1694 {
1695  char path[MAX_PATH];
1696  HRESULT hr;
1697 
1698  if (arg[0] == '1')
1699  {
1700  LPITEMIDLIST pidl;
1701  char *p;
1702 
1703  /* test what happens when CSIDL_FAVORITES is set to a nonexistent directory */
1704 
1705  /* test some failure cases first: */
1706  hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES, NULL, SHGFP_TYPE_CURRENT, path);
1708  "SHGetFolderPath returned 0x%08x, expected 0x80070002\n", hr);
1709 
1710  pidl = NULL;
1711  hr = pSHGetFolderLocation(NULL, CSIDL_FAVORITES, NULL, 0, &pidl);
1713  "SHGetFolderLocation returned 0x%08x\n", hr);
1714  if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
1715 
1716  ok(!pSHGetSpecialFolderPathA(NULL, path, CSIDL_FAVORITES, FALSE),
1717  "SHGetSpecialFolderPath succeeded, expected failure\n");
1718 
1719  pidl = NULL;
1720  hr = pSHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
1722  "SHGetFolderLocation returned 0x%08x\n", hr);
1723 
1724  if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
1725 
1726  /* now test success: */
1727  hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES | CSIDL_FLAG_CREATE, NULL,
1729  ok (hr == S_OK, "got 0x%08x\n", hr);
1730  if (hr == S_OK)
1731  {
1732  BOOL ret;
1733 
1734  trace("CSIDL_FAVORITES was changed to %s\n", path);
1736  ok(!ret, "expected failure with ERROR_ALREADY_EXISTS\n");
1737  if (!ret)
1739  "got %d, expected ERROR_ALREADY_EXISTS\n", GetLastError());
1740 
1741  p = path + strlen(path);
1742  strcpy(p, "\\desktop.ini");
1743  DeleteFileA(path);
1744  *p = 0;
1747  ok( ret, "failed to remove %s error %u\n", path, GetLastError() );
1748  }
1749  }
1750  else if (arg[0] == '2')
1751  {
1752  /* make sure SHGetFolderPath still succeeds when the
1753  original value of CSIDL_FAVORITES is restored. */
1754  hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES | CSIDL_FLAG_CREATE, NULL,
1756  ok(hr == S_OK, "SHGetFolderPath failed: 0x%08x\n", hr);
1757  }
1758 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define E_FAIL
Definition: ddrawi.h:102
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:926
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define trace
Definition: atltest.h:70
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static LPMALLOC pMalloc
Definition: shellpath.c:104
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
#define CSIDL_FLAG_CREATE
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
GLfloat GLfloat p
Definition: glext.h:8902
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

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 }
#define CSIDL_COOKIES
Definition: shlobj.h:2035
Definition: fci.c:115
#define CSIDL_MYVIDEO
Definition: shlobj.h:2017
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2027
#define CSIDL_MYPICTURES
Definition: shlobj.h:2041
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2033
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2026
#define CSIDL_BITBUCKET
Definition: shlobj.h:2013
#define CSIDL_HISTORY
Definition: shlobj.h:2036
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2040
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2053
#define CSIDL_PROFILE
Definition: shlobj.h:2042
#define CSIDL_COMMON_OEM_LINKS
Definition: shlobj.h:2057
#define CSIDL_FONTS
Definition: shlobj.h:2022
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2034
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2047
#define CSIDL_CONTROLS
Definition: shlobj.h:2006
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2044
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2025
#define CSIDL_RECENT
Definition: shlobj.h:2011
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define CSIDL_CONNECTIONS
Definition: shlobj.h:2051
#define CSIDL_PRINTERS
Definition: shlobj.h:2007
#define CSIDL_DRIVES
Definition: shlobj.h:2019
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
#define OLD_CSIDL_MYDOCUMENTS
Definition: shellpath.c:42
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2024
#define CSIDL_WINDOWS
Definition: shlobj.h:2038
#define CSIDL_CDBURN_AREA
Definition: shlobj.h:2058
#define CSIDL_PROFILES
Definition: shellpath.c:231
#define CSIDL_COMMON_ALTSTARTUP
Definition: shlobj.h:2032
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2049
#define CSIDL_ADMINTOOLS
Definition: shlobj.h:2050
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2030
#define CSIDL_SENDTO
Definition: shlobj.h:2012
#define CSIDL_APPDATA
Definition: shlobj.h:2028
Definition: id3.c:18
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2054
#define CSIDL_RESOURCES_LOCALIZED
Definition: shlobj.h:2056
#define CSIDL_COMMON_APPDATA
Definition: shlobj.h:2037
#define CSIDL_PROGRAM_FILES_COMMONX86
Definition: shlobj.h:2046
#define CSIDL_STARTUP
Definition: shlobj.h:2010
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2045
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2052
#define CSIDL_TO_STR(x)
#define CSIDL_RESOURCES
Definition: shlobj.h:2055
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2029
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2048
#define CSIDL_INTERNET
Definition: shlobj.h:2004
#define CSIDL_NETHOOD
Definition: shlobj.h:2021
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
#define CSIDL_STARTMENU
Definition: shlobj.h:2014
#define CSIDL_ALTSTARTUP
Definition: shlobj.h:2031
#define CSIDL_COMPUTERSNEARME
Definition: shlobj.h:2059
#define CSIDL_SYSTEM
Definition: shlobj.h:2039
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2018
#define CSIDL_NETWORK
Definition: shlobj.h:2020
#define CSIDL_PROGRAMS
Definition: shlobj.h:2005
#define CSIDL_TEMPLATES
Definition: shlobj.h:2023
#define CSIDL_SYSTEMX86
Definition: shlobj.h:2043
#define CSIDL_MYMUSIC
Definition: shlobj.h:2016

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 1685 of file shellpath.c.

1686 {
1688  if (!GetCurrentDirectoryA(sizeof(base), base)) return FALSE;
1689  strcpy(selfname, myARGV[0]);
1690  return TRUE;
1691 }
static int myARGC
Definition: shellpath.c:1680
static char ** myARGV
Definition: shellpath.c:1681
#define TRUE
Definition: types.h:120
int winetest_get_mainargs(char ***pargv)
static char selfname[MAX_PATH]
Definition: shellpath.c:1683
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

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 1934 of file shellpath.c.

1935 {
1936  WCHAR wstr[MAX_PATH];
1937 
1938  if(!needle && !hay)
1939  return TRUE;
1940 
1941  while(hay && *hay)
1942  {
1943  DWORD ret;
1944 
1945  if(strcmp(hay, "(null)") == 0 && !needle)
1946  return TRUE;
1947 
1948  ret = MultiByteToWideChar(CP_ACP, 0, hay, -1, wstr, ARRAY_SIZE(wstr));
1949  if(ret == 0)
1950  {
1951  ok(0, "Failed to convert string\n");
1952  return FALSE;
1953  }
1954 
1955  if(lstrcmpW(wstr, needle) == 0)
1956  return TRUE;
1957 
1958  hay += strlen(hay) + 1;
1959  }
1960 
1961  return FALSE;
1962 }
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define MultiByteToWideChar
Definition: compat.h:100
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

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 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal)
Definition: shellole.c:290
STDAPI DllGetVersion(DLLVERSIONINFO *info)
Definition: browseui.cpp:218
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2553
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
const char * LPCSTR
Definition: xmlstorage.h:183
#define trace
Definition: atltest.h:70
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2687
LONG HRESULT
Definition: typedefs.h:77
#define GET_PROC(func)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static LPMALLOC pMalloc
Definition: shellpath.c:104
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2326
#define ok(value,...)
Definition: atltest.h:57
int WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
Definition: shlfileop.cpp:1000
static PIDLIST_ABSOLUTE *static DLLVERSIONINFO shellVersion
Definition: shellpath.c:103
#define GetProcAddress(x, y)
Definition: compat.h:410
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2598
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:319
static HMODULE hShell32
Definition: string.c:34

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 1529 of file shellpath.c.

1530 {
1531  LPITEMIDLIST pidl;
1532  HRESULT hr;
1533 
1534  if (!pSHGetFolderLocation) return;
1535  if (!guid) return;
1536 
1537  pidl = NULL;
1538  hr = pSHGetFolderLocation(NULL, folder, NULL, 0, &pidl);
1539  if (hr == S_OK)
1540  {
1541  LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1542 
1543  if (pidlLast && (pidlLast->mkid.abID[0] == PT_SHELLEXT ||
1544  pidlLast->mkid.abID[0] == PT_GUID))
1545  {
1546  GUID *shellGuid = (GUID *)(pidlLast->mkid.abID + 2);
1547 
1548  if (!guid_alt)
1549  ok(IsEqualIID(shellGuid, guid),
1550  "%s: got GUID %s, expected %s\n", getFolderName(folder),
1551  wine_dbgstr_guid(shellGuid), wine_dbgstr_guid(guid));
1552  else
1553  ok(IsEqualIID(shellGuid, guid) ||
1554  IsEqualIID(shellGuid, guid_alt),
1555  "%s: got GUID %s, expected %s or %s\n", getFolderName(folder),
1556  wine_dbgstr_guid(shellGuid), wine_dbgstr_guid(guid), wine_dbgstr_guid(guid_alt));
1557  }
1558  IMalloc_Free(pMalloc, pidl);
1559  }
1560 }
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
#define PT_SHELLEXT
Definition: shellpath.c:60
const char * wine_dbgstr_guid(const GUID *guid)
const GUID * guid
smooth NULL
Definition: ftsmooth.c:416
#define PT_GUID
Definition: shellpath.c:51
LONG HRESULT
Definition: typedefs.h:77
static const char * getFolderName(int folder)
Definition: shellpath.c:235
static LPMALLOC pMalloc
Definition: shellpath.c:104
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#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 1507 of file shellpath.c.

1508 {
1509  char path[MAX_PATH];
1510 
1511  if (!pSHGetSpecialFolderPathA) return;
1512 
1513  if (pSHGetSpecialFolderPathA(NULL, path, folder, FALSE))
1514  {
1515  char *envVal = getenv(envVar);
1516 
1517  ok(!envVal || !lstrcmpiA(envVal, path),
1518  "%%%s%% does not match SHGetSpecialFolderPath:\n"
1519  "%%%s%% is %s\nSHGetSpecialFolderPath returns %s\n",
1520  envVar, envVar, envVal, path);
1521  }
1522 }
Definition: fci.c:115
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325

Referenced by test_EnvVars().

◆ myPathIsRootA()

static BOOL myPathIsRootA ( LPCSTR  lpszPath)
static

Definition at line 1606 of file shellpath.c.

1607 {
1608  if (lpszPath && *lpszPath &&
1609  lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
1610  return TRUE; /* X:\ */
1611  return FALSE;
1612 }
#define TRUE
Definition: types.h:120

Referenced by myPathRemoveBackslashA().

◆ myPathRemoveBackslashA()

static LPSTR myPathRemoveBackslashA ( LPSTR  lpszPath)
static

Definition at line 1613 of file shellpath.c.

1614 {
1615  LPSTR szTemp = NULL;
1616 
1617  if(lpszPath)
1618  {
1619  szTemp = CharPrevA(lpszPath, lpszPath + strlen(lpszPath));
1620  if (!myPathIsRootA(lpszPath) && *szTemp == '\\')
1621  *szTemp = '\0';
1622  }
1623  return szTemp;
1624 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * LPSTR
Definition: xmlstorage.h:182
smooth NULL
Definition: ftsmooth.c:416
LPSTR WINAPI CharPrevA(_In_ LPCSTR, _In_ LPCSTR)
static BOOL myPathIsRootA(LPCSTR lpszPath)
Definition: shellpath.c:1606

Referenced by testSystemDir(), and testWinDir().

◆ START_TEST()

START_TEST ( shellpath  )

Definition at line 2842 of file shellpath.c.

2843 {
2844  if (!init()) return;
2845 
2846  loadShell32();
2847  pGetSystemWow64DirectoryA = (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
2848  "GetSystemWow64DirectoryA" );
2849  if (myARGC >= 3)
2850  doChild(myARGV[2]);
2851  else
2852  {
2853  /* Report missing functions once */
2854  if (!pSHGetFolderLocation)
2855  win_skip("SHGetFolderLocation is not available\n");
2856 
2857  /* first test various combinations of parameters: */
2858  test_parameters();
2859 
2860  /* check known values: */
2861  test_PidlTypes();
2862  test_GUIDs();
2863  test_EnvVars();
2864  testWinDir();
2865  testSystemDir();
2872  }
2873 }
static void test_PidlTypes(void)
Definition: shellpath.c:1563
static int myARGC
Definition: shellpath.c:1680
static char ** myARGV
Definition: shellpath.c:1681
static void test_SHGetKnownFolderIDList(void)
Definition: shellpath.c:2786
static void doChild(const char *arg)
Definition: shellpath.c:1693
static void test_GUIDs(void)
Definition: shellpath.c:1578
static void test_knownFolders(void)
Definition: shellpath.c:2069
static void test_DoEnvironmentSubst(void)
Definition: shellpath.c:2557
static void test_PathYetAnotherMakeUniqueName(void)
Definition: shellpath.c:2707
static void test_parameters(void)
Definition: shellpath.c:1313
static void loadShell32(void)
Definition: shellpath.c:186
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static void testWinDir(void)
Definition: shellpath.c:1630
static BOOL init(void)
Definition: shellpath.c:1685
static void test_SHGetFolderPathEx(void)
Definition: shellpath.c:1842
static void test_NonExistentPath(void)
Definition: shellpath.c:1773
#define GetProcAddress(x, y)
Definition: compat.h:410
static void testSystemDir(void)
Definition: shellpath.c:1651
#define win_skip
Definition: test.h:141
static void test_EnvVars(void)
Definition: shellpath.c:1593

◆ test_DoEnvironmentSubst()

static void test_DoEnvironmentSubst ( void  )
static

Definition at line 2557 of file shellpath.c.

2558 {
2559  WCHAR expectedW[MAX_PATH];
2560  WCHAR bufferW[MAX_PATH];
2561  CHAR expectedA[MAX_PATH];
2562  CHAR bufferA[MAX_PATH];
2563  DWORD res;
2564  DWORD res2;
2565  DWORD len;
2566  INT i;
2567  static const WCHAR does_not_existW[] = {'%','D','O','E','S','_','N','O','T','_','E','X','I','S','T','%',0};
2568  static const CHAR does_not_existA[] = "%DOES_NOT_EXIST%";
2569  static const CHAR *names[] = {
2570  /* interactive apps and services (works on all windows versions) */
2571  "%ALLUSERSPROFILE%", "%APPDATA%", "%LOCALAPPDATA%",
2572  "%NUMBER_OF_PROCESSORS%", "%OS%", "%PROCESSOR_ARCHITECTURE%",
2573  "%PROCESSOR_IDENTIFIER%", "%PROCESSOR_LEVEL%", "%PROCESSOR_REVISION%",
2574  "%ProgramFiles%", "%SystemDrive%",
2575  "%SystemRoot%", "%USERPROFILE%", "%windir%",
2576  /* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
2577 
2578  /* replace more than one var is allowed */
2579  "%HOMEDRIVE%%HOMEPATH%",
2580  "%OS% %windir%"}; /* always the last entry in the table */
2581 
2582  for (i = 0; i < (ARRAY_SIZE(names)); i++)
2583  {
2584  memset(bufferA, '#', MAX_PATH - 1);
2585  bufferA[MAX_PATH - 1] = 0;
2586  lstrcpyA(bufferA, names[i]);
2587  MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2588 
2589  res2 = ExpandEnvironmentStringsA(names[i], expectedA, MAX_PATH);
2590  res = DoEnvironmentSubstA(bufferA, MAX_PATH);
2591 
2592  /* is the space for the terminating 0 included? */
2593  if (!i && HIWORD(res) && (LOWORD(res) == (lstrlenA(bufferA))))
2594  {
2595  win_skip("DoEnvironmentSubstA/W are broken on NT 4\n");
2596  return;
2597  }
2598  ok(HIWORD(res) && (LOWORD(res) == res2),
2599  "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2600  ok(!lstrcmpA(bufferA, expectedA),
2601  "%d: got %s (expected %s)\n", i, bufferA, expectedA);
2602 
2603  res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2604  res = DoEnvironmentSubstW(bufferW, MAX_PATH);
2605  ok(HIWORD(res) && (LOWORD(res) == res2),
2606  "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2607  ok(!lstrcmpW(bufferW, expectedW),
2608  "%d: got %s (expected %s)\n", i, wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2609  }
2610 
2611  i--; /* reuse data in the last table entry */
2612  len = LOWORD(res); /* needed length */
2613 
2614  /* one character extra is fine */
2615  memset(bufferA, '#', MAX_PATH - 1);
2616  bufferA[len + 2] = 0;
2617  lstrcpyA(bufferA, names[i]);
2618  MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2619 
2620  res2 = ExpandEnvironmentStringsA(bufferA, expectedA, MAX_PATH);
2621  res = DoEnvironmentSubstA(bufferA, len + 1);
2622  ok(HIWORD(res) && (LOWORD(res) == res2),
2623  "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2624  ok(!lstrcmpA(bufferA, expectedA),
2625  "+1: got %s (expected %s)\n", bufferA, expectedA);
2626 
2627  res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2628  res = DoEnvironmentSubstW(bufferW, len + 1);
2629  ok(HIWORD(res) && (LOWORD(res) == res2),
2630  "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2631  ok(!lstrcmpW(bufferW, expectedW),
2632  "+1: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2633 
2634 
2635  /* minimal buffer length (result string and terminating 0) */
2636  memset(bufferA, '#', MAX_PATH - 1);
2637  bufferA[len + 2] = 0;
2638  lstrcpyA(bufferA, names[i]);
2639  MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2640 
2641  /* ANSI version failed without an extra byte, as documented on msdn */
2642  res = DoEnvironmentSubstA(bufferA, len);
2643  ok(!HIWORD(res) && (LOWORD(res) == len),
2644  " 0: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len);
2645  ok(!lstrcmpA(bufferA, names[i]),
2646  " 0: got %s (expected %s)\n", bufferA, names[i]);
2647 
2648  /* DoEnvironmentSubstW works as expected */
2649  res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2650  res = DoEnvironmentSubstW(bufferW, len);
2651  ok(HIWORD(res) && (LOWORD(res) == res2),
2652  " 0: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2653  ok(!lstrcmpW(bufferW, expectedW),
2654  " 0: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2655 
2656 
2657  /* Buffer too small */
2658  /* result: FALSE / provided buffer length / the buffer is untouched */
2659  memset(bufferA, '#', MAX_PATH - 1);
2660  bufferA[len + 2] = 0;
2661  lstrcpyA(bufferA, names[i]);
2662  MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2663 
2664  res = DoEnvironmentSubstA(bufferA, len - 1);
2665  ok(!HIWORD(res) && (LOWORD(res) == (len - 1)),
2666  "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len - 1);
2667  ok(!lstrcmpA(bufferA, names[i]),
2668  "-1: got %s (expected %s)\n", bufferA, names[i]);
2669 
2670  lstrcpyW(expectedW, bufferW);
2671  res = DoEnvironmentSubstW(bufferW, len - 1);
2672  ok(!HIWORD(res) && (LOWORD(res) == (len - 1)),
2673  "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len - 1);
2674  ok(!lstrcmpW(bufferW, expectedW),
2675  "-1: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2676 
2677 
2678  /* unknown variable */
2679  /* result: TRUE / string length including terminating 0 / the buffer is untouched */
2680  memset(bufferA, '#', MAX_PATH - 1);
2681  bufferA[MAX_PATH - 1] = 0;
2682  lstrcpyA(bufferA, does_not_existA);
2683  MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2684 
2685  res2 = lstrlenA(does_not_existA) + 1;
2686  res = DoEnvironmentSubstA(bufferA, MAX_PATH);
2687  ok(HIWORD(res) && (LOWORD(res) == res2),
2688  "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2689  ok(!lstrcmpA(bufferA, does_not_existA),
2690  "%d: got %s (expected %s)\n", i, bufferA, does_not_existA);
2691 
2692  res = DoEnvironmentSubstW(bufferW, MAX_PATH);
2693  ok(HIWORD(res) && (LOWORD(res) == res2),
2694  "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2695  ok(!lstrcmpW(bufferW, does_not_existW),
2696  "%d: got %s (expected %s)\n", i, wine_dbgstr_w(bufferW), wine_dbgstr_w(does_not_existW));
2697 
2698 
2699  if (0)
2700  {
2701  /* NULL crashes on windows */
2704  }
2705 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
char CHAR
Definition: xmlstorage.h:175
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
int32_t INT
Definition: typedefs.h:56
GLuint GLuint * names
Definition: glext.h:11545
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
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:399
DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
Definition: shellord.c:1465
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
Definition: shellord.c:1420
GLenum GLsizei len
Definition: glext.h:6722
static WCHAR does_not_existW[]
Definition: localmon.c:78
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define lstrcpyW
Definition: compat.h:406
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define MultiByteToWideChar
Definition: compat.h:100
GLuint res
Definition: glext.h:9613
#define HIWORD(l)
Definition: typedefs.h:246
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
#define LOWORD(l)
Definition: pedump.c:82

Referenced by START_TEST().

◆ test_EnvVars()

static void test_EnvVars ( void  )
static

Definition at line 1593 of file shellpath.c.

1594 {
1601  /* this is only set on Wine, but can't hurt to verify it: */
1603 }
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2040
#define CSIDL_PROFILE
Definition: shlobj.h:2042
#define CSIDL_WINDOWS
Definition: shlobj.h:2038
#define CSIDL_APPDATA
Definition: shlobj.h:2028
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2045
#define CSIDL_SYSTEM
Definition: shlobj.h:2039
static void matchSpecialFolderPathToEnv(int folder, const char *envVar)
Definition: shellpath.c:1507

Referenced by START_TEST().

◆ test_GUIDs()

static void test_GUIDs ( void  )
static

Definition at line 1578 of file shellpath.c.

1579 {
1580  matchGUID(CSIDL_BITBUCKET, &CLSID_RecycleBin, NULL);
1581  matchGUID(CSIDL_CONTROLS, &CLSID_ControlPanel, NULL);
1582  matchGUID(CSIDL_DRIVES, &CLSID_MyComputer, NULL);
1583  matchGUID(CSIDL_INTERNET, &CLSID_Internet, NULL);
1584  matchGUID(CSIDL_NETWORK, &CLSID_NetworkPlaces, &CLSID_NetworkExplorerFolder); /* Vista and higher */
1585  matchGUID(CSIDL_PERSONAL, &CLSID_MyDocuments, &_CLSID_Documents /* win8 */);
1587  matchGUID(CSIDL_PRINTERS, &CLSID_Printers, NULL);
1588 }
#define CSIDL_BITBUCKET
Definition: shlobj.h:2013
#define CSIDL_CONTROLS
Definition: shlobj.h:2006
#define CSIDL_PRINTERS
Definition: shlobj.h:2007
#define CSIDL_DRIVES
Definition: shlobj.h:2019
static GUID CLSID_CommonDocuments
Definition: shellpath.c:79
smooth NULL
Definition: ftsmooth.c:416
static void matchGUID(int folder, const GUID *guid, const GUID *guid_alt)
Definition: shellpath.c:1529
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2048
#define CSIDL_INTERNET
Definition: shlobj.h:2004
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
#define CSIDL_NETWORK
Definition: shlobj.h:2020

Referenced by START_TEST().

◆ test_knownFolders()

static void test_knownFolders ( void  )
static

Definition at line 2069 of file shellpath.c.

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

Referenced by START_TEST().

◆ test_NonExistentPath()

static void test_NonExistentPath ( void  )
static

Definition at line 1773 of file shellpath.c.

1774 {
1775  static const char userShellFolders[] =
1776  "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
1777  char originalPath[MAX_PATH], modifiedPath[MAX_PATH];
1778  HKEY key;
1779 
1780  if (!pSHGetFolderPathA) return;
1781  if (!pSHGetFolderLocation) return;
1782  if (!pSHGetSpecialFolderPathA) return;
1783  if (!pSHGetSpecialFolderLocation) return;
1784  if (!pSHFileOperationA) return;
1785  if (shellVersion.dwMajorVersion < 5) return;
1786 
1787  if (!RegOpenKeyExA(HKEY_CURRENT_USER, userShellFolders, 0, KEY_ALL_ACCESS,
1788  &key))
1789  {
1790  DWORD len, type;
1791 
1792  len = sizeof(originalPath);
1793  if (!RegQueryValueExA(key, "Favorites", NULL, &type,
1794  (LPBYTE)&originalPath, &len))
1795  {
1796  size_t len = strlen(originalPath);
1797 
1798  memcpy(modifiedPath, originalPath, len);
1799  modifiedPath[len++] = '2';
1800  modifiedPath[len++] = '\0';
1801  trace("Changing CSIDL_FAVORITES to %s\n", modifiedPath);
1802  if (!RegSetValueExA(key, "Favorites", 0, type,
1803  (LPBYTE)modifiedPath, len))
1804  {
1805  char buffer[MAX_PATH+20];
1808 
1809  sprintf(buffer, "%s tests/shellpath.c 1", selfname);
1810  memset(&startup, 0, sizeof(startup));
1811  startup.cb = sizeof(startup);
1812  startup.dwFlags = STARTF_USESHOWWINDOW;
1813  startup.wShowWindow = SW_SHOWNORMAL;
1815  &startup, &info);
1816  winetest_wait_child_process( info.hProcess );
1817 
1818  /* restore original values: */
1819  trace("Restoring CSIDL_FAVORITES to %s\n", originalPath);
1820  RegSetValueExA(key, "Favorites", 0, type, (LPBYTE) originalPath,
1821  strlen(originalPath) + 1);
1822  RegFlushKey(key);
1823 
1824  sprintf(buffer, "%s tests/shellpath.c 2", selfname);
1825  memset(&startup, 0, sizeof(startup));
1826  startup.cb = sizeof(startup);
1827  startup.dwFlags = STARTF_USESHOWWINDOW;
1828  startup.wShowWindow = SW_SHOWNORMAL;
1830  &startup, &info);
1831  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0,
1832  "child process termination\n");
1833  }
1834  }
1835  else skip("RegQueryValueExA(key, Favorites, ...) failed\n");
1836  if (key)
1837  RegCloseKey(key);
1838  }
1839  else skip("RegOpenKeyExA(HKEY_CURRENT_USER, %s, ...) failed\n", userShellFolders);
1840 }
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:4023
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
int startup(int argc, const char *argv[])
Definition: startup.c:430
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
struct _test_info info[]
Definition: SetCursorPos.c:19
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define trace
Definition: atltest.h:70
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4742
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
HKEY key
Definition: reg.c:42
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
void winetest_wait_child_process(HANDLE process)
#define SW_SHOWNORMAL
Definition: winuser.h:764
static char selfname[MAX_PATH]
Definition: shellpath.c:1683
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
static PIDLIST_ABSOLUTE *static DLLVERSIONINFO shellVersion
Definition: shellpath.c:103
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define memset(x, y, z)
Definition: compat.h:39
Definition: path.c:42

Referenced by START_TEST().

◆ test_parameters()

static void test_parameters ( void  )
static

Definition at line 1313 of file shellpath.c.

1314 {
1315  LPITEMIDLIST pidl = NULL;
1316  char path[MAX_PATH];
1317  HRESULT hr;
1318 
1319  if (pSHGetFolderLocation)
1320  {
1321  /* check a bogus CSIDL: */
1322  pidl = NULL;
1323  hr = pSHGetFolderLocation(NULL, 0xeeee, NULL, 0, &pidl);
1324  ok(hr == E_INVALIDARG, "got 0x%08x, expected E_INVALIDARG\n", hr);
1325  if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
1326 
1327  /* check a bogus user token: */
1328  pidl = NULL;
1329  hr = pSHGetFolderLocation(NULL, CSIDL_FAVORITES, (HANDLE)2, 0, &pidl);
1330  ok(hr == E_FAIL || hr == E_HANDLE, "got 0x%08x, expected E_FAIL or E_HANDLE\n", hr);
1331  if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
1332 
1333  /* a NULL pidl pointer crashes, so don't test it */
1334  }
1335 
1336  if (pSHGetSpecialFolderLocation)
1337  {
1338  if (0)
1339  /* crashes */
1341 
1342  hr = pSHGetSpecialFolderLocation(NULL, 0xeeee, &pidl);
1343  ok(hr == E_INVALIDARG, "got returned 0x%08x\n", hr);
1344  }
1345 
1346  if (pSHGetFolderPathA)
1347  {
1348  /* expect 2's a bogus handle, especially since we didn't open it */
1349  hr = pSHGetFolderPathA(NULL, CSIDL_DESKTOP, (HANDLE)2, SHGFP_TYPE_DEFAULT, path);
1350  ok(hr == E_FAIL || hr == E_HANDLE || /* Vista and 2k8 */
1351  broken(hr == S_OK), /* W2k and Me */ "got 0x%08x, expected E_FAIL\n", hr);
1352 
1353  hr = pSHGetFolderPathA(NULL, 0xeeee, NULL, SHGFP_TYPE_DEFAULT, path);
1354  ok(hr == E_INVALIDARG, "got 0x%08x, expected E_INVALIDARG\n", hr);
1355  }
1356 
1357  if (pSHGetSpecialFolderPathA)
1358  {
1359  BOOL ret;
1360 
1361  if (0)
1362  pSHGetSpecialFolderPathA(NULL, NULL, CSIDL_BITBUCKET, FALSE);
1363 
1364  /* odd but true: calling with a NULL path still succeeds if it's a real
1365  * dir (on some windows platform). on winME it generates exception.
1366  */
1367  ret = pSHGetSpecialFolderPathA(NULL, path, CSIDL_PROGRAMS, FALSE);
1368  ok(ret, "got %d\n", ret);
1369 
1370  ret = pSHGetSpecialFolderPathA(NULL, path, 0xeeee, FALSE);
1371  ok(!ret, "got %d\n", ret);
1372  }
1373 }
#define E_HANDLE
Definition: winerror.h:2850
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
#define CSIDL_BITBUCKET
Definition: shlobj.h:2013
#define E_FAIL
Definition: ddrawi.h:102
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
unsigned int BOOL
Definition: ntddk_ex.h:94
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2687
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
int ret
static LPMALLOC pMalloc
Definition: shellpath.c:104
#define broken(x)
Definition: _sntprintf.h:21
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
#define CSIDL_PROGRAMS
Definition: shlobj.h:2005
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by START_TEST().

◆ test_PathYetAnotherMakeUniqueName()

static void test_PathYetAnotherMakeUniqueName ( void  )
static

Definition at line 2707 of file shellpath.c.

2708 {
2709  static const WCHAR shortW[] = {'f','i','l','e','.','t','s','t',0};
2710  static const WCHAR short2W[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
2711  static const WCHAR tmpW[] = {'t','m','p',0};
2712  static const WCHAR longW[] = {'n','a','m','e',0};
2713  static const WCHAR long2W[] = {'n','a','m','e',' ','(','2',')',0};
2714  WCHAR nameW[MAX_PATH], buffW[MAX_PATH], pathW[MAX_PATH];
2715  HANDLE file;
2716  BOOL ret;
2717 
2718  if (!pPathYetAnotherMakeUniqueName)
2719  {
2720  win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
2721  return;
2722  }
2723 
2724 if (0)
2725 {
2726  /* crashes on Windows */
2727  ret = pPathYetAnotherMakeUniqueName(NULL, NULL, NULL, NULL);
2728  ok(!ret, "got %d\n", ret);
2729 
2730  ret = pPathYetAnotherMakeUniqueName(nameW, NULL, NULL, NULL);
2731  ok(!ret, "got %d\n", ret);
2732 }
2733 
2734  GetTempPathW(ARRAY_SIZE(pathW), pathW);
2735 
2736  /* Using short name only first */
2737  nameW[0] = 0;
2738  ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
2739  ok(ret, "got %d\n", ret);
2740  lstrcpyW(buffW, pathW);
2741  lstrcatW(buffW, shortW);
2742  ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2743 
2744  /* now create a file with this name and get next name */
2746  ok(file != NULL, "got %p\n", file);
2747 
2748  nameW[0] = 0;
2749  ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
2750  ok(ret, "got %d\n", ret);
2751  lstrcpyW(buffW, pathW);
2752  lstrcatW(buffW, short2W);
2753  ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2754 
2755  CloseHandle(file);
2756 
2757  /* Using short and long */
2758  nameW[0] = 0;
2759  ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
2760  ok(ret, "got %d\n", ret);
2761  lstrcpyW(buffW, pathW);
2762  lstrcatW(buffW, longW);
2763  ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2764 
2766  ok(file != NULL, "got %p\n", file);
2767 
2768  nameW[0] = 0;
2769  ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
2770  ok(ret, "got %d\n", ret);
2771  lstrcpyW(buffW, pathW);
2772  lstrcatW(buffW, long2W);
2773  ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2774 
2775  CloseHandle(file);
2776 
2777  /* Using long only */
2778  nameW[0] = 0;
2779  ret = pPathYetAnotherMakeUniqueName(nameW, pathW, NULL, longW);
2780  ok(ret, "got %d\n", ret);
2781  lstrcpyW(buffW, pathW);
2782  lstrcatW(buffW, longW);
2783  ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2784 }
#define CloseHandle
Definition: compat.h:398
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR nameW[]
Definition: main.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
const char file[]
Definition: icontest.c:11
#define FILE_FLAG_DELETE_ON_CLOSE
Definition: disk.h:42
int ret
static const WCHAR shortW[]
Definition: tokenize.c:73
#define CREATE_ALWAYS
Definition: disk.h:72
#define lstrcpyW
Definition: compat.h:406
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define CreateFileW
Definition: compat.h:400
static const WCHAR longW[]
Definition: tokenize.c:63
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define win_skip
Definition: test.h:141
Definition: fci.c:126

Referenced by START_TEST().

◆ test_PidlTypes()

static void test_PidlTypes ( void  )
static

Definition at line 1563 of file shellpath.c.

1564 {
1565  /* Desktop */
1568 
1571 }
#define TRUE
Definition: types.h:120
static const struct shellExpectedValues optionalShellValues[]
Definition: shellpath.c:142
static void test_ShellValues(const struct shellExpectedValues testEntries[], int numEntries, BOOL optional)
Definition: shellpath.c:1458
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
static void test_SHGetSpecialFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1443
static void test_SHGetFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1431
static const struct shellExpectedValues requiredShellValues[]
Definition: shellpath.c:118
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by START_TEST().

◆ test_ShellValues()

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

Definition at line 1458 of file shellpath.c.

1460 {
1461  int i;
1462 
1463  for (i = 0; i < numEntries; i++)
1464  {
1465  BYTE type;
1466  int j;
1467  BOOL foundTypeMatch = FALSE;
1468 
1469  if (pSHGetFolderLocation)
1470  {
1471  type = testSHGetFolderLocation(testEntries[i].folder);
1472  for (j = 0; !foundTypeMatch && j < testEntries[i].numTypes; j++)
1473  if (testEntries[i].types[j] == type)
1474  foundTypeMatch = TRUE;
1475  ok(foundTypeMatch || optional || broken(type == 0xff) /* Win9x */,
1476  "%s has unexpected type %d (0x%02x)\n",
1477  getFolderName(testEntries[i].folder), type, type);
1478  }
1479  type = testSHGetSpecialFolderLocation(testEntries[i].folder);
1480  for (j = 0, foundTypeMatch = FALSE; !foundTypeMatch &&
1481  j < testEntries[i].numTypes; j++)
1482  if (testEntries[i].types[j] == type)
1483  foundTypeMatch = TRUE;
1484  ok(foundTypeMatch || optional || broken(type == 0xff) /* Win9x */,
1485  "%s has unexpected type %d (0x%02x)\n",
1486  getFolderName(testEntries[i].folder), type, type);
1487  switch (type)
1488  {
1489  case PT_FOLDER:
1490  case PT_DRIVE:
1491  case PT_DRIVE2:
1492  case PT_IESPECIAL2:
1493  test_SHGetFolderPath(optional, testEntries[i].folder);
1495  break;
1496  }
1497  }
1498 }
#define PT_DRIVE
Definition: shellpath.c:54
static BYTE testSHGetFolderLocation(int folder)
Definition: shellpath.c:1376
#define PT_FOLDER
Definition: shellpath.c:63
#define TRUE
Definition: types.h:120
Definition: fci.c:115
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void test_SHGetSpecialFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1443
static void test_SHGetFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1431
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
unsigned int BOOL
Definition: ntddk_ex.h:94
static BYTE testSHGetSpecialFolderLocation(int folder)
Definition: shellpath.c:1404
#define PT_DRIVE2
Definition: shellpath.c:57
Definition: msg.h:41
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
Definition: cmds.c:130
#define PT_IESPECIAL2
Definition: shellpath.c:76
static const char * getFolderName(int folder)
Definition: shellpath.c:235
unsigned char BYTE
Definition: mem.h:68
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57

Referenced by test_PidlTypes().

◆ test_SHGetFolderPath()

static void test_SHGetFolderPath ( BOOL  optional,
int  folder 
)
static

Definition at line 1431 of file shellpath.c.

1432 {
1433  char path[MAX_PATH];
1434  HRESULT hr;
1435 
1436  if (!pSHGetFolderPathA) return;
1437 
1438  hr = pSHGetFolderPathA(NULL, folder, NULL, SHGFP_TYPE_CURRENT, path);
1439  ok(hr == S_OK || optional,
1440  "SHGetFolderPathA(NULL, %s, NULL, SHGFP_TYPE_CURRENT, path) failed: 0x%08x\n", getFolderName(folder), hr);
1441 }
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
smooth NULL
Definition: ftsmooth.c:416
Definition: msg.h:41
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const char * getFolderName(int folder)
Definition: shellpath.c:235
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325

Referenced by test_PidlTypes(), and test_ShellValues().

◆ test_SHGetFolderPathEx()

static void test_SHGetFolderPathEx ( void  )
static

Definition at line 1842 of file shellpath.c.

1843 {
1845  unsigned int i;
1846  HRESULT hr;
1847  DWORD len;
1848 
1849  if (!pSHGetKnownFolderPath || !pSHGetFolderPathEx)
1850  {
1851  win_skip("SHGetKnownFolderPath or SHGetFolderPathEx not available\n");
1852  return;
1853  }
1854 
1855 if (0) { /* crashes */
1856  hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, NULL);
1857  ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1858 }
1859  /* non-existent folder id */
1860  path = (void *)0xdeadbeef;
1861  hr = pSHGetKnownFolderPath(&IID_IOleObject, 0, NULL, &path);
1862  ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
1863  ok(path == NULL, "got %p\n", path);
1864 
1865  path = NULL;
1866  hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, KF_FLAG_DEFAULT_PATH, NULL, &path);
1867  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1868  ok(path != NULL, "expected path != NULL\n");
1870 
1871  for (i = 0; i < ARRAY_SIZE(known_folders); ++i)
1872  {
1873  const KNOWNFOLDERID *folder_id = known_folders[i].folderId;
1874 
1875  path = NULL;
1876  hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_DEFAULT, NULL, &path);
1877  if (FAILED(hr))
1878  continue;
1879  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1880  ok(path != NULL, "expected path != NULL\n");
1881 
1882  path2 = NULL;
1883  hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_SIMPLE_IDLIST, NULL, &path2);
1884  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1885  ok(path2 != NULL, "expected path != NULL\n");
1886  ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1888 
1889  path2 = NULL;
1890  hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_DONT_UNEXPAND, NULL, &path2);
1891  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1892  ok(path2 != NULL, "expected path != NULL\n");
1893  ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1895 
1896  path2 = NULL;
1897  hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL, &path2);
1898  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1899  ok(path2 != NULL, "expected path != NULL\n");
1900  ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1902 
1904  }
1905 
1906  path = NULL;
1907  hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, &path);
1908  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1909  ok(path != NULL, "expected path != NULL\n");
1910 
1911  hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, MAX_PATH);
1912  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1913  ok(!lstrcmpiW(path, buffer), "expected equal paths\n");
1914  len = lstrlenW(buffer);
1916 
1917  hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, 0);
1918  ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1919 
1920 if (0) { /* crashes */
1921  hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, NULL, len + 1);
1922  ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1923 
1924  hr = pSHGetFolderPathEx(NULL, 0, NULL, buffer, MAX_PATH);
1925  ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1926 }
1927  hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len);
1928  ok(hr == E_NOT_SUFFICIENT_BUFFER, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr);
1929 
1930  hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len + 1);
1931  ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1932 }
static const WCHAR path2[]
Definition: path.c:29
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
HRESULT hr
Definition: shlfolder.c:183
GLsizei const GLchar ** path
Definition: glext.h:7234
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
GLuint buffer
Definition: glext.h:5915
#define lstrlenW
Definition: compat.h:407
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
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 E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
const GUID IID_IOleObject
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
#define win_skip
Definition: test.h:141
static const struct knownFolderDef known_folders[]
Definition: shellpath.c:343

Referenced by START_TEST().

◆ test_SHGetKnownFolderIDList()

static void test_SHGetKnownFolderIDList ( void  )
static

Definition at line 2786 of file shellpath.c.

2787 {
2788  PIDLIST_ABSOLUTE pidl;
2789  HRESULT hr;
2790 
2791  if (!pSHGetKnownFolderIDList)
2792  {
2793  win_skip("SHGetKnownFolderIDList is not available.\n");
2794  return;
2795  }
2796 
2797  hr = pSHGetKnownFolderIDList(NULL, 0, NULL, NULL);
2798  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2799 
2800 if (0) { /* crashes on native */
2801  pidl = (void*)0xdeadbeef;
2802  hr = pSHGetKnownFolderIDList(NULL, 0, NULL, &pidl);
2803 }
2804  /* not a known folder */
2805  pidl = (void*)0xdeadbeef;
2806  hr = pSHGetKnownFolderIDList(&IID_IUnknown, 0, NULL, &pidl);
2807  ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
2808  ok(pidl == NULL, "got %p\n", pidl);
2809 
2810  hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, NULL);
2811  ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2812 
2813  pidl = (void*)0xdeadbeef;
2814  hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, &pidl);
2815  ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2816  ok(ILIsEmpty(pidl), "pidl should be empty.\n");
2817  ok(pidl->mkid.cb == 0, "get wrong value: %d\n", pidl->mkid.cb);
2818  ILFree(pidl);
2819 
2820  pidl = (void*)0xdeadbeef;
2821  hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, KF_FLAG_NO_ALIAS, NULL, &pidl);
2822  ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2823  todo_wine ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2824  todo_wine ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2825  ILFree(pidl);
2826 
2827  pidl = (void*)0xdeadbeef;
2828  hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, 0, NULL, &pidl);
2829  ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2830  ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2831  ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2832  ILFree(pidl);
2833 
2834  pidl = (void*)0xdeadbeef;
2835  hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, KF_FLAG_NO_ALIAS, NULL, &pidl);
2836  ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2837  ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2838  ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2839  ILFree(pidl);
2840 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
WORD cb
Definition: shtypes.idl:27
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define todo_wine
Definition: test.h:154
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
static BOOL ILIsEmpty(_In_opt_ LPCITEMIDLIST pidl)
Definition: shlobj.h:2310
SHITEMID mkid
Definition: shtypes.idl:34
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_SHGetSpecialFolderPath()

static void test_SHGetSpecialFolderPath ( BOOL  optional,
int  folder 
)
static

Definition at line 1443 of file shellpath.c.

1444 {
1445  char path[MAX_PATH];
1446  BOOL ret;
1447 
1448  if (!pSHGetSpecialFolderPathA) return;
1449 
1450  ret = pSHGetSpecialFolderPathA(NULL, path, folder, FALSE);
1451  if (ret && winetest_interactive)
1452  printf("%s: %s\n", getFolderName(folder), path);
1453  ok(ret || optional,
1454  "SHGetSpecialFolderPathA(NULL, path, %s, FALSE) failed\n",
1456 }
Definition: fci.c:115
int winetest_interactive
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: msg.h:41
#define MAX_PATH
Definition: compat.h:26
int ret
static const char * getFolderName(int folder)
Definition: shellpath.c:235
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
#define printf
Definition: config.h:203

Referenced by test_PidlTypes(), and test_ShellValues().

◆ testSHGetFolderLocation()

static BYTE testSHGetFolderLocation ( int  folder)
static

Definition at line 1376 of file shellpath.c.

1377 {
1378  LPITEMIDLIST pidl;
1379  HRESULT hr;
1380  BYTE ret = 0xff;
1381 
1382  /* treat absence of function as success */
1383  if (!pSHGetFolderLocation) return TRUE;
1384 
1385  pidl = NULL;
1386  hr = pSHGetFolderLocation(NULL, folder, NULL, 0, &pidl);
1387  if (hr == S_OK)
1388  {
1389  if (pidl)
1390  {
1391  LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1392 
1393  ok(pidlLast != NULL, "%s: ILFindLastID failed\n",
1395  if (pidlLast)
1396  ret = pidlLast->mkid.abID[0];
1397  IMalloc_Free(pMalloc, pidl);
1398  }
1399  }
1400  return ret;
1401 }
#define TRUE
Definition: types.h:120
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
int ret
static const char * getFolderName(int folder)
Definition: shellpath.c:235
unsigned char BYTE
Definition: mem.h:68
static LPMALLOC pMalloc
Definition: shellpath.c:104
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by test_ShellValues().

◆ testSHGetSpecialFolderLocation()

static BYTE testSHGetSpecialFolderLocation ( int  folder)
static

Definition at line 1404 of file shellpath.c.

1405 {
1406  LPITEMIDLIST pidl;
1407  HRESULT hr;
1408  BYTE ret = 0xff;
1409 
1410  /* treat absence of function as success */
1411  if (!pSHGetSpecialFolderLocation) return TRUE;
1412 
1413  pidl = NULL;
1414  hr = pSHGetSpecialFolderLocation(NULL, folder, &pidl);
1415  if (hr == S_OK)
1416  {
1417  if (pidl)
1418  {
1419  LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1420 
1421  ok(pidlLast != NULL,
1422  "%s: ILFindLastID failed\n", getFolderName(folder));
1423  if (pidlLast)
1424  ret = pidlLast->mkid.abID[0];
1425  IMalloc_Free(pMalloc, pidl);
1426  }
1427  }
1428  return ret;
1429 }
#define TRUE
Definition: types.h:120
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
int ret
static const char * getFolderName(int folder)
Definition: shellpath.c:235
unsigned char BYTE
Definition: mem.h:68
static LPMALLOC pMalloc
Definition: shellpath.c:104
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by test_ShellValues().

◆ testSystemDir()

static void testSystemDir ( void  )
static

Definition at line 1651 of file shellpath.c.

1652 {
1653  char systemShellPath[MAX_PATH], systemDir[MAX_PATH], systemDirx86[MAX_PATH];
1654 
1655  if (!pSHGetSpecialFolderPathA) return;
1656 
1657  GetSystemDirectoryA(systemDir, sizeof(systemDir));
1658  myPathRemoveBackslashA(systemDir);
1659  if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEM, FALSE))
1660  {
1661  myPathRemoveBackslashA(systemShellPath);
1662  ok(!lstrcmpiA(systemDir, systemShellPath),
1663  "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1664  systemDir, systemShellPath);
1665  }
1666 
1667  if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDirx86, sizeof(systemDirx86)))
1668  GetSystemDirectoryA(systemDirx86, sizeof(systemDirx86));
1669  myPathRemoveBackslashA(systemDirx86);
1670  if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE))
1671  {
1672  myPathRemoveBackslashA(systemShellPath);
1673  ok(!lstrcmpiA(systemDirx86, systemShellPath) || broken(!lstrcmpiA(systemDir, systemShellPath)),
1674  "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1675  systemDir, systemShellPath);
1676  }
1677 }
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#define CSIDL_SYSTEM
Definition: shlobj.h:2039
#define CSIDL_SYSTEMX86
Definition: shlobj.h:2043
static LPSTR myPathRemoveBackslashA(LPSTR lpszPath)
Definition: shellpath.c:1613

Referenced by START_TEST().

◆ testWinDir()

static void testWinDir ( void  )
static

Definition at line 1630 of file shellpath.c.

1631 {
1632  char windowsShellPath[MAX_PATH], windowsDir[MAX_PATH] = { 0 };
1633 
1634  if (!pSHGetSpecialFolderPathA) return;
1635 
1636  if (pSHGetSpecialFolderPathA(NULL, windowsShellPath, CSIDL_WINDOWS, FALSE))
1637  {
1638  myPathRemoveBackslashA(windowsShellPath);
1639  GetWindowsDirectoryA(windowsDir, sizeof(windowsDir));
1640  myPathRemoveBackslashA(windowsDir);
1641  ok(!lstrcmpiA(windowsDir, windowsShellPath),
1642  "GetWindowsDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1643  windowsDir, windowsShellPath);
1644  }
1645 }
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
smooth NULL
Definition: ftsmooth.c:416
#define CSIDL_WINDOWS
Definition: shlobj.h:2038
#define MAX_PATH
Definition: compat.h:26
#define ok(value,...)
Definition: atltest.h:57
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
static LPSTR myPathRemoveBackslashA(LPSTR lpszPath)
Definition: shellpath.c:1613

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 1682 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.

Referenced by _SHRegisterUserShellFolders().

◆ 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 1311 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.

Referenced by PathCleanupSpec().

◆ LPWSTR

Definition at line 99 of file shellpath.c.

◆ myARGC

int myARGC
static

Definition at line 1680 of file shellpath.c.

Referenced by init(), and START_TEST().

◆ myARGV

char** myARGV
static

Definition at line 1681 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:
= { PT_FOLDER, PT_GUID, PT_DRIVE, 0xff ,
#define PT_DRIVE
Definition: shellpath.c:54
#define PT_FOLDER
Definition: shellpath.c:63
#define PT_SHELLEXT
Definition: shellpath.c:60
#define PT_GUID
Definition: shellpath.c:51
#define PT_IESPECIAL2
Definition: shellpath.c:76

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
Initial value:
= {
}
#define CSIDL_COOKIES
Definition: shlobj.h:2035
static const BYTE folderOrSpecialType[]
Definition: shellpath.c:109
static const BYTE favoritesType[]
Definition: shellpath.c:108
#define CSIDL_BITBUCKET
Definition: shlobj.h:2013
#define CSIDL_FONTS
Definition: shlobj.h:2022
#define CSIDL_CONTROLS
Definition: shlobj.h:2006
#define CSIDL_RECENT
Definition: shlobj.h:2011
#define CSIDL_PRINTERS
Definition: shlobj.h:2007
#define CSIDL_DRIVES
Definition: shlobj.h:2019
#define DECLARE_TYPE(x, y)
Definition: shellpath.c:117
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
static const BYTE guidType[]
Definition: shellpath.c:105
static const BYTE personalType[]
Definition: shellpath.c:110
#define CSIDL_SENDTO
Definition: shlobj.h:2012
static const BYTE folderType[]
Definition: shellpath.c:107
static const BYTE printersType[]
Definition: shellpath.c:113
#define CSIDL_STARTUP
Definition: shlobj.h:2010
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2029
#define CSIDL_INTERNET
Definition: shlobj.h:2004
#define CSIDL_NETHOOD
Definition: shlobj.h:2021
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
#define CSIDL_STARTMENU
Definition: shlobj.h:2014
static const BYTE controlPanelType[]
Definition: shellpath.c:106
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2018
#define CSIDL_NETWORK
Definition: shlobj.h:2020
#define CSIDL_PROGRAMS
Definition: shlobj.h:2005
#define CSIDL_TEMPLATES
Definition: shlobj.h:2023

Definition at line 118 of file shellpath.c.

Referenced by test_PidlTypes().

◆ selfname

char selfname[MAX_PATH]
static

Definition at line 1683 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.