reactos/dll/shellext/fontext/fontpidl.cpp
Mark Jansen d9e7c48c1a
[FONTEXT] Initial implementation
Create Fonts\desktop.ini when registering the shell ext
Also list the shell extension as needing to be registered at install
CORE-14690
2019-10-19 18:42:15 +02:00

39 lines
1.1 KiB
C++

/*
* PROJECT: ReactOS Font Shell Extension
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: pidl handling
* COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
*/
#include "precomp.h"
LPITEMIDLIST _ILCreate(LPCWSTR lpString, ULONG Index)
{
// Because the FontPidlEntry contains one WCHAR, we do not need to take the null terminator into account
size_t cbData = sizeof(FontPidlEntry) + wcslen(lpString) * sizeof(WCHAR);
FontPidlEntry* pidl = (FontPidlEntry*)CoTaskMemAlloc(cbData + sizeof(WORD));
if (!pidl)
return NULL;
ZeroMemory(pidl, cbData + sizeof(WORD));
pidl->cb = (WORD)cbData;
pidl->Magic = 'fp';
pidl->Index = Index;
wcscpy(pidl->Name, lpString);
// Should be zero already, but make sure it is
*(WORD*)((char*)pidl + cbData) = 0;
return (LPITEMIDLIST)pidl;
}
const FontPidlEntry* _FontFromIL(LPCITEMIDLIST pidl)
{
const FontPidlEntry* zipPidl = (const FontPidlEntry*)pidl;
if (zipPidl->Magic == 'fp')
return zipPidl;
return NULL;
}