0
我有一個應用程序CMFCShellTreeCtrl的對話框之一,它在運行一些Win8機器時崩潰。它發生時,樹型控件試圖初始化並調用的SHGetFileInfo在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;
}
應用是建立在VS2010上的Win7 32位。 我無法在VM上覆制此錯誤,因此我在客戶端PC上進行遠程調試。 我比較了SHGetFileInfo函數的參數值,它們在我的機器和客戶端上看起來是一樣的,除了內存地址。異常後
調用堆棧: screenshot
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引起異常的原因。
你確定'pItem-> pidlFQ'有效嗎?那個'CoInitialize' /'OleInitialize'已經在線程中調用了? –
Jonathan,謝謝,CoInitialize在OnInitDialog()開頭解決問題。 –