我建立了一个dll工程,并在这个工程中做了一个具有类似于CFileDialog功能的一个类名叫CNFileDlgEx,然后叫另一个exe文件来调用它,这个类CNFileDlgEx是一个模式对话框,当我第一次调用它时各种文件的图标都能显示出来,但是我关闭它后又再一次启动它,所有图标都没有了。经我察看发现SHGetFileInfo中的参数SHFILEINFO中的hicon返回的句柄为空,但是我把exe工程关掉再一次启动它就好使了,但是关掉CNFileDlgEx是一个模式对话框再次启动就不行,不只是为什么?哪位高手给指点一下,不胜感激!

解决方案 »

  1.   

    哈哈,资源没有被释放掉,你好好看看MSDN关于这个函数的re部分。
      

  2.   

    什么资源没有被释放呀,是hicon吗但是我没有用SHGFI_ICON这个掩码,请您明示。
      

  3.   

    我以前遇到过你这样的问题,你仔细看一下,这个函数的使用说明,我这里是公用上网机,没有MSDN,这个问题很好解决,只要你仔细看一下。抱歉了
      

  4.   

    If SHGetFileInfo returns an icon handle in the hIcon member of the SHFILEINFO structure pointed to by psfi, you are responsible for freeing it with DestroyIcon when you no longer need it.Note  Once you have a handle to a system image list, you can use the Image List API to manipulate it like any other image list. Because system image lists are created on a per-process basis, you should treat them as read-only objects. Writing to a system image list may overwrite or delete one of the system images, making it unavailable or incorrect for the remainder of the process.
      

  5.   

    http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/functions/shgetfileinfo.aspNote  Once you have a handle to a system image list, you can use the Image List API to manipulate it like any other image list. Because system image lists are created on a per-process basis, you should treat them as read-only objects. Writing to a system image list may overwrite or delete one of the system images, making it unavailable or incorrect for the remainder of the process.
      

  6.   

    能不能给个例子,msdn的方法我都用过了。