ReactOS 0.4.16-dev-2224-g3637fd8
fontext.cpp File Reference
#include "precomp.h"
#include "undocgdi.h"
Include dependency graph for fontext.cpp:

Go to the source code of this file.

Classes

class  CFontExtModule
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (fontext)
 
STDAPI DllCanUnloadNow ()
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
STDAPI DllRegisterServer ()
 
STDAPI DllUnregisterServer ()
 
void CloseRegKeyArray (HKEY *array, UINT cKeys)
 
LSTATUS AddClassKeyToArray (const WCHAR *szClass, HKEY *array, UINT *cKeys)
 
HRESULT InstallFontFiles (_Inout_ PINSTALL_FONT_DATA pData)
 
HRESULT DoInstallFontFile (_In_ PCWSTR pszFontPath, _In_ PCWSTR pszFontsDir, _In_ HKEY hkeyFonts)
 
HRESULT DoGetFontTitle (_In_ LPCWSTR pszFontPath, _Out_ CStringW &strFontName)
 
BOOL CheckDropFontFiles (HDROP hDrop)
 
BOOL CheckDataObject (IDataObject *pDataObj)
 
static DWORD WINAPI InstallThreadProc (LPVOID lpParameter)
 
static INT_PTR CALLBACK InstallDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, PINSTALL_FONT_DATA pData)
 
static INT_PTR CALLBACK InstallDialogProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HRESULT InstallFontsFromDataObject (HWND hwndView, IDataObject *pDataObj)
 
EXTERN_C BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 

Variables

const GUID CLSID_CFontExt = { 0xbd84b380, 0x8ca2, 0x1069, { 0xab, 0x1d, 0x08, 0x00, 0x09, 0x48, 0xf5, 0x34 } }
 
LONG g_ModuleRefCnt
 
CFontExtModule gModule
 

Function Documentation

◆ AddClassKeyToArray()

LSTATUS AddClassKeyToArray ( const WCHAR szClass,
HKEY array,
UINT cKeys 
)

Definition at line 109 of file fontext.cpp.

110{
111 if (*cKeys >= 16)
112 return ERROR_MORE_DATA;
113
114 HKEY hkey;
116 if (result == ERROR_SUCCESS)
117 {
118 array[*cKeys] = hkey;
119 *cKeys += 1;
120 }
121 return result;
122}
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
GLuint64EXT * result
Definition: glext.h:11304
#define KEY_READ
Definition: nt_native.h:1026
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
Definition: undname.c:54
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by CDrivesContextMenu_CreateInstance(), ClassPropDialogInitCallback(), CFontExt::CreateForegroundMenu(), CDesktopFolder::CreateViewObject(), CFSFolder::CreateViewObject(), CRegItemContextMenu_CreateInstance(), CDesktopFolder::GetUIObjectOf(), and CNetFolder::GetUIObjectOf().

◆ CheckDataObject()

BOOL CheckDataObject ( IDataObject pDataObj)

Definition at line 308 of file fontext.cpp.

309{
310 STGMEDIUM stg;
311 FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
312 HRESULT hr = pDataObj->GetData(&etc, &stg);
314 return FALSE;
315 HDROP hDrop = reinterpret_cast<HDROP>(stg.hGlobal);
316 BOOL bOK = CheckDropFontFiles(hDrop);
317 ReleaseStgMedium(&stg);
318 return bOK;
319}
#define CF_HDROP
Definition: constants.h:410
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:30
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL CheckDropFontFiles(HDROP hDrop)
Definition: fontext.cpp:289
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
HRESULT hr
Definition: shlfolder.c:183

Referenced by CFontExt::DragEnter(), InstallFontsFromDataObject(), and CFontBackgroundMenu::InvokeCommand().

◆ CheckDropFontFiles()

BOOL CheckDropFontFiles ( HDROP  hDrop)

Definition at line 289 of file fontext.cpp.

290{
291 UINT cFiles = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
292 if (cFiles == 0)
293 return FALSE;
294
295 for (UINT iFile = 0; iFile < cFiles; ++iFile)
296 {
297 WCHAR szFile[MAX_PATH];
298 if (!DragQueryFileW(hDrop, iFile, szFile, _countof(szFile)))
299 return FALSE;
300 LPCWSTR pchDotExt = PathFindExtensionW(szFile);
301 if (!IsFontDotExt(pchDotExt))
302 return FALSE;
303 }
304
305 return TRUE;
306}
#define TRUE
Definition: types.h:120
BOOL IsFontDotExt(LPCWSTR pchDotExt)
Definition: precomp.h:56
#define MAX_PATH
Definition: compat.h:34
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1274
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:666
unsigned int UINT
Definition: ndis.h:50
#define _countof(array)
Definition: sndvol32.h:70
_In_ ULONG_PTR iFile
Definition: winddi.h:3835
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CheckDataObject().

◆ CloseRegKeyArray()

void CloseRegKeyArray ( HKEY array,
UINT  cKeys 
)

Definition at line 103 of file fontext.cpp.

104{
105 for (UINT i = 0; i < cKeys; ++i)
107}
#define RegCloseKey(hKey)
Definition: registry.h:49
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

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 39 of file fontext.cpp.

40{
42 return S_FALSE;
43 return gModule.DllCanUnloadNow();
44}
HRESULT DllCanUnloadNow()
Definition: atlbase.h:1030
LONG g_ModuleRefCnt
Definition: fontext.cpp:36
CFontExtModule gModule
Definition: fontext.cpp:37
#define S_FALSE
Definition: winerror.h:3451

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 46 of file fontext.cpp.

47{
48 return gModule.DllGetClassObject(rclsid, riid, ppv);
49}
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:1037
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ DllMain()

EXTERN_C BOOL WINAPI DllMain ( HINSTANCE  hInstance,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 440 of file fontext.cpp.

441{
442 switch (dwReason)
443 {
446 gModule.Init(ObjectMap, hInstance, NULL);
447 break;
449 gModule.Term();
450 break;
451 }
452
453 return TRUE;
454}
DWORD dwReason
Definition: misc.cpp:135
HINSTANCE hInstance
Definition: charmap.c:19
void Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE h, const GUID *plibid)
Definition: fontext.cpp:18
void Term()
Definition: fontext.cpp:24
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 51 of file fontext.cpp.

52{
53 WCHAR Path[MAX_PATH] = { 0 };
54 static const char DesktopIniContents[] = "[.ShellClassInfo]\r\n"
55 "CLSID={BD84B380-8CA2-1069-AB1D-08000948F534}\r\n"
56 "IconResource=%SystemRoot%\\system32\\shell32.dll,-39\r\n"; // IDI_SHELL_FONTS_FOLDER
58 HRESULT hr;
59
62 return hr;
63
66 return hr;
67
68 // Make this a system folder:
69 // Ideally this should not be done here, but when installing
70 // Otherwise, livecd won't have this set properly
73 {
76 }
77 else
78 {
79 ERR("Unable to get attributes for fonts folder (%d)\n", GetLastError());
80 }
81
82 if (!PathAppendW(Path, L"desktop.ini"))
83 return E_FAIL;
84
88
89 DWORD BytesWritten, BytesToWrite = strlen(DesktopIniContents);
90 if (WriteFile(hFile, DesktopIniContents, (DWORD)BytesToWrite, &BytesWritten, NULL))
91 hr = (BytesToWrite == BytesWritten) ? S_OK : E_FAIL;
92 else
95 return hr;
96}
PRTL_UNICODE_STRING_BUFFER Path
#define ERR(fmt,...)
Definition: precomp.h:57
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:1042
#define E_FAIL
Definition: ddrawi.h:102
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2716
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:52
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define GENERIC_WRITE
Definition: nt_native.h:90
#define PathAppendW
Definition: pathcch.h:310
#define CSIDL_FONTS
Definition: shlobj.h:2198
DWORD dwAttributes
Definition: vdmdbg.h:34
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 98 of file fontext.cpp.

99{
101}
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:1047

◆ DoGetFontTitle()

HRESULT DoGetFontTitle ( _In_ LPCWSTR  pszFontPath,
_Out_ CStringW strFontName 
)

Definition at line 256 of file fontext.cpp.

259{
260 DWORD cbInfo = 0;
261 BOOL ret = GetFontResourceInfoW(pszFontPath, &cbInfo, NULL, 1);
262 if (!ret || !cbInfo)
263 {
264 ERR("GetFontResourceInfoW failed (err: %u)\n", GetLastError());
265 return E_FAIL;
266 }
267
268 LPWSTR pszBuffer = strFontName.GetBuffer(cbInfo / sizeof(WCHAR));
269 ret = GetFontResourceInfoW(pszFontPath, &cbInfo, pszBuffer, 1);
271 strFontName.ReleaseBuffer();
272 if (!ret)
273 {
274 ERR("GetFontResourceInfoW failed (err: %u)\n", dwErr);
275 return E_FAIL;
276 }
277
278 LPCWSTR pchDotExt = PathFindExtensionW(pszFontPath);
279 if (!StrCmpIW(pchDotExt, L".ttf") || !StrCmpIW(pchDotExt, L".ttc") ||
280 !StrCmpIW(pchDotExt, L".otf") || !StrCmpIW(pchDotExt, L".otc"))
281 {
282 strFontName += L" (TrueType)";
283 }
284
285 TRACE("pszFontName: %S\n", (LPCWSTR)strFontName);
286 return S_OK;
287}
DWORD dwErr
Definition: service.c:36
int WINAPI StrCmpIW(const WCHAR *str, const WCHAR *comp)
Definition: string.c:456
return ret
Definition: mutex.c:146
BOOL WINAPI GetFontResourceInfoW(LPCWSTR lpFileName, DWORD *pdwBufSize, void *lpBuffer, DWORD dwType)
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DoInstallFontFile(), and CFontFolderViewCB::TranslatePidl().

◆ DoInstallFontFile()

HRESULT DoInstallFontFile ( _In_ PCWSTR  pszFontPath,
_In_ PCWSTR  pszFontsDir,
_In_ HKEY  hkeyFonts 
)

Definition at line 181 of file fontext.cpp.

185{
186 ATLASSERT(pszFontPath);
187 ATLASSERT(pszFontsDir);
188 ATLASSERT(hkeyFonts);
189
190 // Add this font to the font list, so we can query the name
191 if (!AddFontResourceW(pszFontPath))
192 {
193 ERR("AddFontResourceW('%S') failed\n", pszFontPath);
194 return E_FAIL;
195 }
196
197 // Get the font name
198 CStringW strFontName;
199 HRESULT hr = DoGetFontTitle(pszFontPath, strFontName);
201 return hr;
202
203 // Remove it now
204 // WINDOWS BUG: Removing once is not enough
205 for (INT iTry = 0; iTry < 3; ++iTry)
206 {
207 if (!RemoveFontResourceW(pszFontPath) &&
208 !RemoveFontResourceExW(pszFontPath, FR_PRIVATE, NULL))
209 {
210 break;
211 }
212 }
213
214 // Delete font entry in registry
215 RegDeleteValueW(hkeyFonts, strFontName);
216
217 LPCWSTR pszFileTitle = PathFindFileName(pszFontPath);
218 ATLASSERT(pszFileTitle);
219
220 // Build destination path
221 CStringW szDestFile(pszFontsDir); // pszFontsDir has backslash at back
222 szDestFile += pszFileTitle;
223 TRACE("szDestFile: '%S'\n", (PCWSTR)szDestFile);
224
225 if (!StrCmpIW(szDestFile, pszFontPath)) // Same file?
226 {
227 ERR("Wrongly same: %S\n", pszFontPath);
228 return E_FAIL;
229 }
230
231 // Copy file
232 if (!CopyFileW(pszFontPath, szDestFile, FALSE))
233 {
234 ERR("CopyFileW('%S', '%S') failed\n", pszFontPath, (PCWSTR)szDestFile);
235 return E_FAIL;
236 }
237
238 // Write registry for font entry
239 DWORD cbData = (wcslen(pszFileTitle) + 1) * sizeof(WCHAR);
240 LONG nError = RegSetValueExW(hkeyFonts, strFontName, 0, REG_SZ,
241 (const BYTE *)pszFileTitle, cbData);
242 if (nError)
243 {
244 ERR("RegSetValueExW failed with %ld\n", nError);
245 DeleteFileW(szDestFile);
246 return E_FAIL;
247 }
248
249 // Notify file creation
251
252 return AddFontResourceW(szDestFile) ? S_OK : E_FAIL;
253}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
HRESULT DoGetFontTitle(_In_ LPCWSTR pszFontPath, _Out_ CStringW &strFontName)
Definition: fontext.cpp:256
#define REG_SZ
Definition: layer.c:22
long LONG
Definition: pedump.c:60
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
#define PathFindFileName
Definition: shlwapi.h:469
#define SHCNE_CREATE
Definition: shlobj.h:1896
#define SHCNF_PATHW
Definition: shlobj.h:1931
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI RemoveFontResourceExW(_In_ LPCWSTR lpFileName, _In_ DWORD fl, _In_opt_ PVOID pdv)
Definition: font.c:2232
int WINAPI AddFontResourceW(_In_ LPCWSTR pszFilename)
Definition: font.c:2167
BOOL WINAPI RemoveFontResourceW(_In_ LPCWSTR)
Definition: font.c:2175
unsigned char BYTE
Definition: xxhash.c:193

Referenced by InstallFontFiles().

◆ InstallDialogProc()

static INT_PTR CALLBACK InstallDialogProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 377 of file fontext.cpp.

378{
380 if (uMsg == WM_INITDIALOG)
381 {
384 }
385
387 return InstallDlgProc(hwnd, uMsg, wParam, lParam, pData);
388}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct tagINSTALL_FONT_DATA * PINSTALL_FONT_DATA
static INT_PTR CALLBACK InstallDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, PINSTALL_FONT_DATA pData)
Definition: fontext.cpp:335
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4931
#define WM_INITDIALOG
Definition: winuser.h:1767
#define SetWindowLongPtrW
Definition: winuser.h:5457

Referenced by InstallFontsFromDataObject().

◆ InstallDlgProc()

static INT_PTR CALLBACK InstallDlgProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
PINSTALL_FONT_DATA  pData 
)
static

Definition at line 335 of file fontext.cpp.

336{
337 switch (uMsg)
338 {
339 case WM_INITDIALOG:
340 {
341 pData->hwnd = hwnd;
342 ATLASSERT(pData->cSteps >= 0);
345 {
346 WARN("!SHCreateThread\n");
347 pData->pDataObj->Release();
348 pData->hrResult = E_ABORT;
350 }
351 return TRUE;
352 }
353 case WM_COMMAND:
354 {
355 switch (LOWORD(wParam))
356 {
357 case IDOK:
359 break;
360 case IDCANCEL:
361 pData->bCanceled = TRUE;
363 break;
364 case IDCONTINUE:
365 pData->iStep += 1;
366 ATLASSERT(pData->iStep <= pData->cSteps);
368 break;
369 }
370 break;
371 }
372 }
373 return 0;
374}
#define WARN(fmt,...)
Definition: precomp.h:61
#define IDC_INSTALL_PROGRESS
Definition: resource.h:5
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
static DWORD WINAPI InstallThreadProc(LPVOID lpParameter)
Definition: fontext.cpp:321
#define LOWORD(l)
Definition: pedump.c:82
#define PBM_SETPOS
Definition: commctrl.h:2189
#define PBM_SETRANGE
Definition: commctrl.h:2188
@ CTF_COINIT
Definition: shlwapi.h:75
#define IDCONTINUE
Definition: vfdguiut.c:42
#define E_ABORT
Definition: winerror.h:3481
#define MAKELPARAM(l, h)
Definition: winuser.h:4110
#define IDCANCEL
Definition: winuser.h:842
#define WM_COMMAND
Definition: winuser.h:1768
#define IDOK
Definition: winuser.h:841
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDABORT
Definition: winuser.h:843
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by InstallDialogProc().

◆ InstallFontFiles()

HRESULT InstallFontFiles ( _Inout_ PINSTALL_FONT_DATA  pData)

Definition at line 125 of file fontext.cpp.

127{
128 PCUIDLIST_ABSOLUTE pidlParent = pData->pidlParent;
129 UINT cidl = pData->cSteps;
130 PCUITEMID_CHILD_ARRAY apidl = pData->apidl;
131
132 CAtlArray<CStringW> FontPaths;
133 for (UINT n = 0; n < cidl; ++n)
134 {
136 pidl.Attach(ILCombine(pidlParent, apidl[n]));
137 if (!pidl)
138 {
139 ERR("Out of memory\n");
140 return E_OUTOFMEMORY;
141 }
142
146 {
147 ERR("Not font file: %s\n", wine_dbgstr_w(szPath));
148 return E_FAIL;
149 }
150
151 FontPaths.Add(szPath);
152 }
153
154 CRegKey keyFonts;
155 if (keyFonts.Open(FONT_HIVE, FONT_KEY, KEY_WRITE) != ERROR_SUCCESS)
156 {
157 ERR("CRegKey::Open failed\n");
158 return E_FAIL;
159 }
160
161 for (SIZE_T iItem = 0; iItem < FontPaths.GetCount(); ++iItem)
162 {
163 if (pData->bCanceled)
164 {
165 WARN("Canceled\n");
166 return E_ABORT;
167 }
168
169 HRESULT hr = DoInstallFontFile(FontPaths[iItem], g_FontCache->FontPath(), keyFonts);
171 return hr;
172
173 if (pData->hwnd)
175 }
176
177 return S_OK;
178}
CFontCache * g_FontCache
Definition: CFontCache.cpp:12
size_t Add(INARGTYPE element)
Definition: atlcoll.h:295
size_t GetCount() const
Definition: atlcoll.h:373
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) noexcept
Definition: atlbase.h:1173
const CStringW & FontPath() const
Definition: CFontCache.hpp:51
void Attach(T *lp)
Definition: atlalloc.h:162
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FONT_HIVE
Definition: precomp.h:49
#define FONT_KEY
Definition: precomp.h:50
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1729
HRESULT DoInstallFontFile(_In_ PCWSTR pszFontPath, _In_ PCWSTR pszFontsDir, _In_ HKEY hkeyFonts)
Definition: fontext.cpp:181
GLdouble n
Definition: glext.h:7729
#define wine_dbgstr_w
Definition: kernel32.h:34
LPCWSTR szPath
Definition: env.c:37
#define KEY_WRITE
Definition: nt_native.h:1034
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
const ITEMIDLIST_ABSOLUTE UNALIGNED * PCUIDLIST_ABSOLUTE
Definition: shtypes.idl:63
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
ULONG_PTR SIZE_T
Definition: typedefs.h:80
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by InstallThreadProc().

◆ InstallFontsFromDataObject()

HRESULT InstallFontsFromDataObject ( HWND  hwndView,
IDataObject pDataObj 
)

Definition at line 390 of file fontext.cpp.

391{
392 if (!CheckDataObject(pDataObj))
393 {
394 ERR("!CheckDataObject\n");
395 return E_FAIL;
396 }
397
398 CDataObjectHIDA cida(pDataObj);
399 if (!cida || cida->cidl <= 0)
400 {
401 ERR("E_UNEXPECTED\n");
402 return E_FAIL;
403 }
404
405 PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(cida);
406 if (!pidlParent)
407 {
408 ERR("pidlParent is NULL\n");
409 return E_FAIL;
410 }
411
413 for (UINT n = 0; n < cida->cidl; ++n)
414 {
415 PCUIDLIST_RELATIVE pidlRelative = HIDA_GetPIDLItem(cida, n);
416 if (!pidlRelative)
417 {
418 ERR("!pidlRelative\n");
419 return E_FAIL;
420 }
421 apidl.Add(pidlRelative);
422 }
423
424 // Show progress dialog
426 data.pDataObj = pDataObj;
427 data.pidlParent = pidlParent;
428 data.apidl = &apidl[0];
429 data.cSteps = cida->cidl;
430 pDataObj->AddRef();
431 DialogBoxParamW(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCEW(IDD_INSTALL),
432 hwndView, InstallDialogProc, (LPARAM)&data);
433 if (data.bCanceled)
434 return S_FALSE;
435
436 return FAILED_UNEXPECTEDLY(data.hrResult) ? E_FAIL : S_OK;
437}
#define IDD_INSTALL
Definition: resource.h:3
BOOL CheckDataObject(IDataObject *pDataObj)
Definition: fontext.cpp:308
static INT_PTR CALLBACK InstallDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontext.cpp:377
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
ULONG AddRef()
LONG_PTR LPARAM
Definition: minwindef.h:175
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:713
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:708
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by CFontExt::Drop().

◆ InstallThreadProc()

static DWORD WINAPI InstallThreadProc ( LPVOID  lpParameter)
static

Definition at line 321 of file fontext.cpp.

322{
325 pData->hrResult = InstallFontFiles(pData);
326 if (pData->bCanceled)
327 pData->hrResult = S_FALSE;
328 TRACE("hrResult: 0x%08X\n", pData->hrResult);
330 pData->pDataObj->Release();
331 return 0;
332}
HRESULT InstallFontFiles(_Inout_ PINSTALL_FONT_DATA pData)
Definition: fontext.cpp:125

Referenced by InstallDlgProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( fontext  )

Variable Documentation

◆ CLSID_CFontExt

const GUID CLSID_CFontExt = { 0xbd84b380, 0x8ca2, 0x1069, { 0xab, 0x1d, 0x08, 0x00, 0x09, 0x48, 0xf5, 0x34 } }

Definition at line 13 of file fontext.cpp.

Referenced by CFontExt::GetClassID().

◆ g_ModuleRefCnt

LONG g_ModuleRefCnt

Definition at line 36 of file fontext.cpp.

Referenced by DllCanUnloadNow().

◆ gModule