具体是这样的,
程序运行时想将ico或bmp文件加载进取,得到HICON类型的句柄
像LoadIcon只能从executable file中加载icon,而我想要从.ico这样的文件中加载请问什么函数可以做到,谢谢

解决方案 »

  1.   

    LoadImage
    把uType指定为IMAGE_ICON
      

  2.   

    实在不好意思,没说清楚,其实我是在WinCE下编程,
    WinCE下的LoadImage函数好像不支持LR_LOADFROMFILE,所以这个函数也不能从ico文件载入icon
    我想知道有没有别的方法呢
      

  3.   

    LoadImage不支持LR_LOADFROMFILE?????
    那怎么办,用LoadReource????
      

  4.   

    用ExtractIcon(HINSTANCE hInst,LPCTSTR lpszExeFileName,UINT nIconIndex)获得HICON,然后用SetIcon()显示出来就好了.
      

  5.   

    Microsoft Windows CE 3.0   LoadImage
    uType 
    [in] Specifies the type of image to be loaded. This parameter can be one of the following values: Value Description 
    IMAGE_BITMAP Loads a bitmap. 
    IMAGE_CURSOR Loads a cursor. 
    IMAGE_ICON Loads an icon. 
      

  6.   

    lpszName 
    [in] Identifies the image to load. If the hinst parameter is non-NULL and the fuLoad parameter does not include LR_LOADFROMFILE, lpszName is a pointer to a null-terminated string that contains the name of the image resource in the hinst module. 
    If hinst is NULL and LR_LOADFROMFILE is not specified, the low-order word of this parameter must be the identifier of the OEM image to load. The OEM image identifiers are defined in Winuser.h and have the following prefixes: Prefix Description 
    OBM_ OEM bitmaps 
    OIC_ OEM icons 
    OCR_ OEM cursors If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the image. 
      

  7.   

    我没试过,从描述上看,LR_LOADFROMFILE还是有效的。
      

  8.   

    用ExtractIcon(HINSTANCE hInst,LPCTSTR lpszExeFileName,UINT nIconIndex)获得HICON,然后用SetIcon()显示出来就好了.
    --------------------------------------------------------------------------------------
    Sorry,说错了,是:用ExtractIcon(HINSTANCE hInst,LPCTSTR lpszExeFileName,UINT nIconIndex)获得HICON,然后用DrawIconEx()把图标在指定的区域画出来。