按照本演练,演示如何使用字体而不必在C ++中安装它:http://www.codeproject.com/Articles/42041/How-to-Use-a-Font-Without-Installing-it我在ntdll.dll中收到了地址违规错误(0xc0000005)
DialogEx :: OnInitDialog()继承函数中的调用代码如下:
Gdiplus::PrivateFontCollection m_fontcollection;
HINSTANCE instance = AfxGetResourceHandle();
HRSRC res = FindResource(instance, MAKEINTRESOURCE(IDR_MAIN_FONT), L"BINARY");
HGLOBAL mem = LoadResource(instance, res);
void *data = LockResource(mem);
size_t len = SizeofResource(instance, res);
Gdiplus::Status Result = m_fontcollection.AddMemoryFont(data, len); // Exception arises
我调试了电话,一切看起来都不错。长度匹配,没有NullPointers ......
异常发生在gdiplusfontcollection.h
inline Status
PrivateFontCollection::AddMemoryFont(IN const void* memory,
IN INT length)
{
return SetStatus(DllExports::GdipPrivateAddMemoryFont(
nativeFontCollection,
memory,
length));
}
无法进一步调试......
如何找出函数调用中出错的方法?
答案 0 :(得分:-1)
似乎nativeFontCollection
为空。 GdiplusStartup
method must be called before。不要忘记之后再致电GdiplusShutdown
。