当前位置: 代码迷 >> VFP >> 怎么获得任意文件扩展名关联的图标
  详细解决方案

怎么获得任意文件扩展名关联的图标

热度:939   发布时间:2013-02-26 00:00:00.0
求助:如何获得任意文件扩展名关联的图标
本人想根据任意文件扩展名得到关联的图标,比如:bmp、pdf、xls、doc、txt等等,网上也搜了相关内容,有得到“EXE、dll”文件的图标,也有用非VFP代码获得图标的程序,就是没有找到VFP的。
以下是excel论坛有人用VBA编的可以实现,有哪位高人能将他转换为VFP的代码,要么谁有其他现成的相关VFP代码分享一下,谢谢!

http://www.officefans.net/cdb/viewthread.php?tid=77504


*----------------------------------
Option Explicit

Private Const MAX_PATH = 260
Private Type BITMAPINFOHEADER       '40   bytes
    biSize   As Long
    biWidth   As Long
    biHeight   As Long
    biPlanes   As Integer
    biBitCount   As Integer
    biCompression   As Long
    biSizeImage   As Long
    biXPelsPerMeter   As Long
    biYPelsPerMeter   As Long
    biClrUsed   As Long
    biClrImportant   As Long
End Type

Private Type RGBQUAD
    rgbBlue   As Byte
    rgbGreen   As Byte
    rgbRed   As Byte
    rgbReserved   As Byte
End Type

Private Type BITMAPINFO
    bmiHeader   As BITMAPINFOHEADER
    bmiColors   As RGBQUAD
End Type


Private Type SHFILEINFO
    hIcon As Long                      '  out: icon
    iIcon As Long          '  out: icon index
    dwAttributes As Long               '  out: SFGAO_ flags
    szDisplayName As String * 260 '  out: display name (or path)
    szTypeName As String * 80         '  out: type name
End Type


Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateDIBSection Lib "gdi32" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByVal lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
  相关解决方案