ReactOS  0.4.15-dev-509-g96a357b
precomp.h File Reference
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <atlbase.h>
#include <atlcom.h>
#include <shellapi.h>
#include <shlwapi.h>
#include <strsafe.h>
#include <shellutils.h>
#include <apitest.h>
#include "resource.h"
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define InitializeShellFolder(Filename, pFolder)   InitializeShellFolder_(__FILE__, __LINE__, Filename, pFolder)
 
#define IsFormatAdvertised(pDataObj, cfFormat, tymed)   IsFormatAdvertised_(__FILE__, __LINE__, pDataObj, cfFormat, tymed)
 
#define ok_displayname(pFolder, pidl, Flags, Name)   ok_displayname_(__FILE__, __LINE__, pFolder, pidl, Flags, Name)
 

Functions

BOOL extract_resource (WCHAR *Filename, LPCWSTR ResourceName, WCHAR *ParentFolder)
 
bool InitializeShellFolder_ (const char *file, int line, const WCHAR *Filename, CComPtr< IShellFolder > &spFolder)
 
bool IsFormatAdvertised_ (const char *file, int line, IDataObject *pDataObj, CLIPFORMAT cfFormat, TYMED tymed)
 
void ok_displayname_ (const char *file, int line, IShellFolder *pFolder, PCUITEMID_CHILD pidl, SHGDNF Flags, LPCWSTR Name)
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 5 of file precomp.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 6 of file precomp.h.

◆ InitializeShellFolder

#define InitializeShellFolder (   Filename,
  pFolder 
)    InitializeShellFolder_(__FILE__, __LINE__, Filename, pFolder)

Definition at line 25 of file precomp.h.

◆ IsFormatAdvertised

#define IsFormatAdvertised (   pDataObj,
  cfFormat,
  tymed 
)    IsFormatAdvertised_(__FILE__, __LINE__, pDataObj, cfFormat, tymed)

Definition at line 28 of file precomp.h.

◆ ok_displayname

#define ok_displayname (   pFolder,
  pidl,
  Flags,
  Name 
)    ok_displayname_(__FILE__, __LINE__, pFolder, pidl, Flags, Name)

Definition at line 31 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 4 of file precomp.h.

Function Documentation

◆ extract_resource()

BOOL extract_resource ( WCHAR Filename,
LPCWSTR  ResourceName,
WCHAR ParentFolder 
)

Definition at line 39 of file IDataObject.cpp.

40 {
42  UINT TickMask = 0xffff;
43  if (!ParentFolder)
44  {
46  ParentFolder = workdir;
47  }
48  else
49  {
50  // Fixed filename
51  TickMask = 0;
52  }
53  StringCchPrintfW(Filename, MAX_PATH, L"%sTMP%u.zip", ParentFolder, GetTickCount() & TickMask);
54 
56  HRSRC hRsrc = FindResourceW(hMod, ResourceName, MAKEINTRESOURCEW(RT_RCDATA));
57  ok(!!hRsrc, "Unable to find %s\n", wine_dbgstr_w(ResourceName));
58  if (!hRsrc)
59  return FALSE;
60 
61  HGLOBAL hGlobal = LoadResource(hMod, hRsrc);
62  DWORD Size = SizeofResource(hMod, hRsrc);
63  LPVOID pData = LockResource(hGlobal);
64 
65  ok(Size && !!pData, "Unable to load %s\n", wine_dbgstr_w(ResourceName));
66  if (!Size || !pData)
67  return FALSE;
68 
69  BOOL Written = write_raw_file(Filename, pData, Size);
71  return Written;
72 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:934
#define UnlockResource(h)
Definition: winbase.h:3212
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
static BOOL write_raw_file(const WCHAR *FileName, const void *Data, DWORD Size)
Definition: IDataObject.cpp:21
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
static char workdir[MAX_PATH]
Definition: batch.c:26
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RT_RCDATA
Definition: pedump.c:372
static const WCHAR L[]
Definition: oid.c:1250
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define ok(value,...)
Definition: atltest.h:57
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
unsigned int UINT
Definition: ndis.h:50
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by START_TEST().

◆ InitializeShellFolder_()

bool InitializeShellFolder_ ( const char file,
int  line,
const WCHAR Filename,
CComPtr< IShellFolder > &  spFolder 
)

Definition at line 74 of file IDataObject.cpp.

75 {
76  CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidl;
77  HRESULT hr;
78  ok_hr_(file, line, (hr = SHParseDisplayName(Filename, NULL, &pidl, 0, NULL)), S_OK);
79  if (!SUCCEEDED(hr))
80  return false;
81 
82  CComPtr<IShellFolder> spParent;
83  PCUIDLIST_RELATIVE pidlLast;
84  ok_hr_(file, line, (hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &spParent), &pidlLast)), S_OK);
85  if (!SUCCEEDED(hr))
86  return false;
87 
88  ok_hr_(file, line, (hr = spParent->BindToObject(pidlLast, 0, IID_PPV_ARG(IShellFolder, &spFolder))), S_OK);
89 
90  return SUCCEEDED(hr);
91 }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:934
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define ok_hr_(file, line, status, expected)
Definition: apitest.h:36
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1331
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1375
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: fci.c:126

◆ IsFormatAdvertised_()

bool IsFormatAdvertised_ ( const char file,
int  line,
IDataObject pDataObj,
CLIPFORMAT  cfFormat,
TYMED  tymed 
)

Definition at line 114 of file IDataObject.cpp.

115 {
116  CComPtr<IEnumFORMATETC> pEnumFmt;
117  HRESULT hr = pDataObj->EnumFormatEtc(DATADIR_GET, &pEnumFmt);
118 
119  ok_hex_(file, line, hr, S_OK);
120  if (!SUCCEEDED(hr))
121  return false;
122 
123  FORMATETC fmt;
124  while (S_OK == (hr = pEnumFmt->Next(1, &fmt, NULL)))
125  {
126  if (fmt.cfFormat == cfFormat)
127  {
128  ok_hex_(file, line, fmt.lindex, -1);
129  if (tymed)
130  ok_hex_(file, line, fmt.tymed, tymed);
131  return true;
132  }
133  }
134  ok_hex_(file, line, hr, S_FALSE);
135  return false;
136 }
HRESULT hr
Definition: shlfolder.c:183
#define ok_hex_(expression, result)
const char * fmt
Definition: wsprintf.c:30
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
HRESULT EnumFormatEtc([in] DWORD dwDirection, [out] IEnumFORMATETC **ppenumFormatEtc)
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59
static DWORD tymed
Definition: url.c:174
Definition: dsound.c:943
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: fci.c:126

◆ ok_displayname_()

void ok_displayname_ ( const char file,
int  line,
IShellFolder pFolder,
PCUITEMID_CHILD  pidl,
SHGDNF  Flags,
LPCWSTR  Name 
)

Definition at line 12 of file EnumObjects.cpp.

13 {
14  STRRET NameRet;
15  HRESULT hr;
16 
17  hr = pFolder->GetDisplayNameOf(pidl, Flags, &NameRet);
18  ok_hr_(file, line, hr, S_OK);
19  if (!SUCCEEDED(hr))
20  return;
21 
22  WCHAR DisplayName[MAX_PATH];
23  hr = StrRetToBufW(&NameRet, pidl, DisplayName, RTL_NUMBER_OF(DisplayName));
24  ok_hr_(file, line, hr, S_OK);
25  if (!SUCCEEDED(hr))
26  return;
27 
28  ok_wstr_(file, line, DisplayName, Name);
29 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
Definition: parser.c:48
#define ok_wstr_(file, line, x, y)
Definition: test.h:870
#define ok_hr_(file, line, status, expected)
Definition: apitest.h:36
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define MAX_PATH
Definition: compat.h:26
#define S_OK
Definition: intsafe.h:59
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: fci.c:126