SHGetFileInfo函数导致未处理的异常

SHGetFileInfo函数导致未处理的异常

本文介绍了SHGetFileInfo函数导致未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在其中一个对话框上有CMFCShellTreeCtrl应用程序,在某些Win8机器上运行时崩溃了。它发生在树控制尝试初始化并在afxshelltreectrl.cpp的这一部分调用SHGetFileInfo时:



Hello all,

I have application with CMFCShellTreeCtrl on one of it's dialog and it is crashing when running on some Win8 machines. It happen when tree control trying to initialize and calls SHGetFileInfo in this part of afxshelltreectrl.cpp:

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日志:





Application was build in VS2010 on Win7 32-bit.
I could not replicate this bug on VM so I debug remotely on client PC.
I compared the values ​​of arguments for SHGetFileInfo function, and they looked the same on my machine and the client's, except the memory addresses.

Call stack after exception:
http://bayimg.com/JaALkaAff[^]

WinDbg log:

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导致异常的原因。



According to the call stack error occurs in some COM functions.
I am not familiar with COM so may be some one can help me to find the reason why SHGetFileInfo cause exception.

推荐答案

CoInitializeEx()

OnInitDialog()

的开头解决问题。


这篇关于SHGetFileInfo函数导致未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:44