*/
#include "precomp.h"
+#include "undocgdi.h" // for GetFontResourceInfoW
WINE_DEFAULT_DEBUG_CHANNEL(fontext);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
-#if 1 // Please implement DoGetFontTitle
- return DRAGDROP_S_CANCEL;
-#else
*pdwEffect = DROPEFFECT_COPY;
return S_OK;
-#endif
}
STDMETHODIMP CFontExt::DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
WCHAR szDestFile[MAX_PATH];
LPCWSTR pszFileTitle = PathFindFileName(pszFontPath);
- WCHAR szFontName[512];
- if (!DoGetFontTitle(pszFontPath, szFontName))
+ CStringW strFontName;
+ if (!DoGetFontTitle(pszFontPath, strFontName))
return E_FAIL;
RemoveFontResourceW(pszFileTitle);
return E_FAIL;
}
- if (!AddFontResourceW(pszFileTitle))
+ if (!AddFontResourceW(szDestFile))
{
ERR("AddFontResourceW('%S') failed\n", pszFileTitle);
DeleteFileW(szDestFile);
}
DWORD cbData = (wcslen(pszFileTitle) + 1) * sizeof(WCHAR);
- LONG nError = RegSetValueExW(hkeyFonts, szFontName, 0, REG_SZ, (const BYTE *)szFontName, cbData);
+ LONG nError = RegSetValueExW(hkeyFonts, strFontName, 0, REG_SZ,
+ (const BYTE *)pszFileTitle, cbData);
if (nError)
{
ERR("RegSetValueExW failed with %ld\n", nError);
return S_OK;
}
-HRESULT CFontExt::DoGetFontTitle(LPCWSTR pszFontPath, LPCWSTR pszFontName)
+HRESULT
+CFontExt::DoGetFontTitle(IN LPCWSTR pszFontPath, OUT CStringW& strFontName)
{
- // TODO:
+ DWORD cbInfo = 0;
+ BOOL ret = GetFontResourceInfoW(pszFontPath, &cbInfo, NULL, 1);
+ if (!ret || !cbInfo)
+ {
+ ERR("GetFontResourceInfoW failed\n");
+ return E_FAIL;
+ }
+
+ LPWSTR pszBuffer = strFontName.GetBuffer(cbInfo / sizeof(WCHAR));
+ ret = GetFontResourceInfoW(pszFontPath, &cbInfo, pszBuffer, 1);
+ strFontName.ReleaseBuffer();
+ if (ret)
+ {
+ TRACE("pszFontName: %S\n", (LPCWSTR)strFontName);
+ return S_OK;
+ }
+
+ ERR("GetFontResourceInfoW failed\n");
return E_FAIL;
}
#ifndef _UNDOCGDI_H
#define _UNDOCGDI_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define DS_TILE 0x2
#define DS_TRANSPARENTALPHA 0x4
#define DS_TRANSPARENTCLR 0x8
DWORD crTransparent; // transparent color.
} GDI_DRAW_STREAM, *PGDI_DRAW_STREAM;
-BOOL
-WINAPI
-GdiDrawStream(HDC dc, ULONG l, PGDI_DRAW_STREAM pDS);
+BOOL WINAPI GdiDrawStream(HDC dc, ULONG l, PGDI_DRAW_STREAM pDS);
-BOOL
-WINAPI
+BOOL WINAPI
GetTextExtentExPointWPri(
HDC hdc,
- LPCWSTR lpwsz,
+ LPCWSTR lpwsz,
INT cwc,
- INT dxMax,
- LPINT pcCh,
- LPINT pdxOut,
+ INT dxMax,
+ LPINT pcCh,
+ LPINT pdxOut,
LPSIZE psize);
-#endif
\ No newline at end of file
+BOOL WINAPI
+GetFontResourceInfoW(
+ _In_z_ LPCWSTR lpFileName,
+ _Inout_ DWORD *pdwBufSize,
+ _Out_writes_to_opt_(*pdwBufSize, 1) PVOID lpBuffer,
+ _In_ DWORD dwType);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif