mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:13:03 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
98
modules/rostests/apitests/shell32/shelltest.cpp
Normal file
98
modules/rostests/apitests/shell32/shelltest.cpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
#include "shelltest.h"
|
||||
#include <atlbase.h>
|
||||
#include <atlcom.h>
|
||||
|
||||
|
||||
// + Adapted from https://blogs.msdn.microsoft.com/oldnewthing/20130503-00/?p=4463/
|
||||
// In short: We want to create an IDLIST from an item that does not exist,
|
||||
// so we have to provide WIN32_FIND_DATAW in a bind context.
|
||||
// If we don't, the FS will be queried, and we do not get a valid IDLIST for a non-existing path.
|
||||
|
||||
CComModule gModule;
|
||||
|
||||
class CFileSysBindData :
|
||||
public CComCoClass<CFileSysBindData>,
|
||||
public CComObjectRootEx<CComMultiThreadModelNoCS>,
|
||||
public IFileSystemBindData
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE SetFindData(const WIN32_FIND_DATAW *pfd)
|
||||
{
|
||||
m_Data = *pfd;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetFindData(WIN32_FIND_DATAW *pfd)
|
||||
{
|
||||
*pfd = m_Data;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
DECLARE_NOT_AGGREGATABLE(CFileSysBindData)
|
||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
BEGIN_COM_MAP(CFileSysBindData)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IFileSystemBindData, IFileSystemBindData)
|
||||
END_COM_MAP()
|
||||
private:
|
||||
WIN32_FIND_DATAW m_Data;
|
||||
};
|
||||
|
||||
static
|
||||
HRESULT
|
||||
AddFileSysBindCtx(_In_ IBindCtx *pbc)
|
||||
{
|
||||
CComPtr<IFileSystemBindData> spfsbc(new CComObject<CFileSysBindData>());
|
||||
WIN32_FIND_DATAW wfd = { 0 };
|
||||
wfd.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||
spfsbc->SetFindData(&wfd);
|
||||
HRESULT hr = pbc->RegisterObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, spfsbc);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
static
|
||||
HRESULT
|
||||
CreateBindCtxWithOpts(_In_ BIND_OPTS *pbo, _Outptr_ IBindCtx **ppbc)
|
||||
{
|
||||
CComPtr<IBindCtx> spbc;
|
||||
HRESULT hr = CreateBindCtx(0, &spbc);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = spbc->SetBindOptions(pbo);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
}
|
||||
*ppbc = SUCCEEDED(hr) ? spbc.Detach() : NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT
|
||||
CreateFileSysBindCtx(_Outptr_ IBindCtx **ppbc)
|
||||
{
|
||||
CComPtr<IBindCtx> spbc;
|
||||
BIND_OPTS bo = { sizeof(bo), 0, STGM_CREATE, 0 };
|
||||
HRESULT hr = CreateBindCtxWithOpts(&bo, &spbc);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = AddFileSysBindCtx(spbc);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
}
|
||||
*ppbc = SUCCEEDED(hr) ? spbc.Detach() : NULL;
|
||||
return hr;
|
||||
}
|
||||
|
||||
VOID
|
||||
PathToIDList(LPCWSTR pszPath, ITEMIDLIST** ppidl)
|
||||
{
|
||||
CComPtr<IBindCtx> spbc;
|
||||
HRESULT hr = CreateFileSysBindCtx(&spbc);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = SHParseDisplayName(pszPath, spbc, ppidl, 0, NULL);
|
||||
ok(hr == S_OK, "hr = %lx\n", hr);
|
||||
}
|
||||
}
|
||||
|
||||
// - Adapted from https://blogs.msdn.microsoft.com/oldnewthing/20130503-00/?p=4463/
|
Loading…
Add table
Add a link
Reference in a new issue