我在其中一个对话框上有带有 CMFCShellTreeCtrl 的应用程序,在某些 Win8 机器上运行时它崩溃了。当树控件尝试在 afxshelltreectrl.cpp 的这一部分中初始化并调用 SHGetFileInfo 时会发生这种情况:
int CMFCShellTreeCtrl::OnGetItemIcon(LPAFX_SHELLITEMINFO pItem, BOOL bSelected)
{
ENSURE(pItem != NULL);
SHFILEINFO sfi;
UINT uiFlags = SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON;
if (bSelected)
{
uiFlags |= SHGFI_OPENICON;
}
else
{
uiFlags |= SHGFI_LINKOVERLAY;
}
if (SHGetFileInfo((LPCTSTR)pItem->pidlFQ, 0, &sfi, sizeof(sfi), uiFlags))
{
return sfi.iIcon;
}
return -1;
}
应用程序是在 Win7 32 位的 VS2010 中构建的。我无法在 VM 上复制此错误,因此我在客户端 PC 上进行了远程调试。我比较了 SHGetFileInfo 函数的参数值,它们在我的机器和客户端上看起来是一样的,除了内存地址。
异常后调用堆栈: 截图
WinDbg 日志:
ModLoad: 02b70000 02bc9000 cmd.exe
ModLoad: 60780000 607ca000 C:\windows\SysWOW64\mscoree.dll
ModLoad: 60700000 6077a000 C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
ModLoad: 711b0000 71250000 C:\windows\SysWOW64\sxs.dll
ModLoad: 60150000 606ff000 C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
ModLoad: 70e30000 70ecb000 C:\windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6910_none_d089c358442de345\MSVCR80.dll
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6910_none_d089c358442de345\MSVCR80.dll -
ModLoad: 5f650000 6014a000 C:\windows\assembly\NativeImages_v2.0.50727_32\mscorlib\7f763721bf47dc8d58ec21cb64cbec91\mscorlib.ni.dll
ModLoad: 71770000 71778000 C:\Windows\Microsoft.NET\Framework\v2.0.50727\culture.dll
(c18.227c): CLR exception - code e0434f4d (first chance)
(c18.227c): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\windows\SysWOW64\combase.dll -
eax=002d0068 ebx=80040154 ecx=04b1f654 edx=04b1f678 esi=0018b654 edi=76cbbda0
eip=002d0068 esp=0018b63c ebp=0018b648 iopl=0 nv up ei ng nz ac pe cy
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010297
002d0068 ?? ???
根据调用堆栈错误发生在某些 COM 函数中。我不熟悉 COM,所以可能有人可以帮助我找到 SHGetFileInfo 导致异常的原因。