????? ??????? ?????? SHGetFileInfo ?????? ??? ?????? ???? ????? ??????? ?? Visual Basic .NET

?????? ????????? ?????? ?????????
???? ???????: 319340 - ??? ???????? ???? ????? ????? ??? ???????.
?????? ??? ????? Microsoft Visual C# .NET ?? ??? ???????? ???? 319350.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ??????? ?????? SHGetFileInfo ?????? ??? ?????? ???? ????? ???????.

????? ????? Windows ???????

  1. ??? ????? Microsoft Visual Studio .NET.
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
  3. ?? ???? ?????? ????? ???? ? ???? ??? ?????? Visual Basic ??? ????? Project ?? ???? ??? ????? Windows ??? ?????.
  4. ?? ?????? ?????? ???? GetIconSample.

?????? ?????? SHGetFileInfo

  1. ?? ?????? ????????? ???????? ??????? ?? ????? ????? Form1.vb.
    Imports System.Runtime.InteropServices
    					
  2. ?? ?????? ????????? ???????? ??????? ?? ??? Form1 ??? ??????? INHERITS.
    Private Structure SHFILEINFO
            Public hIcon As IntPtr ' : icon
            Public iIcon As Integer ' : icondex
            Public dwAttributes As Integer ' : SFGAO_ flags
            <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
            Public szDisplayName As String
            <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> _
            Public szTypeName As String
    End Structure
    
    Private Declare Ansi Function SHGetFileInfo Lib "shell32.dll" (ByVal pszPath As String, _
    ByVal dwFileAttributes As Integer, ByRef psfi As SHFILEINFO, ByVal cbFileInfo As Integer, _
    ByVal uFlags As Integer) As IntPtr
    
    Private Const SHGFI_ICON = &H100
    Private Const SHGFI_SMALLICON = &H1
    Private Const SHGFI_LARGEICON = &H0         ' Large icon
    Private nIndex = 0
    					
  3. ????? ???? ???? ??? ???? ???? ?? ??????? imageList ??? ???????. ?? ??????? ?????????? ListView1 ? Button1 ImageList1 ??? ???????.
  4. ?? ?????? "?????" ?? Button1 ????? ?? ???? ??? ????? ??? ?? ?? ?????? ???????? ???????? ??????? ?? ????? Button1_click:
    Dim hImgSmall As IntPtr  'The handle to the system image list.
    Dim hImgLarge As IntPtr  'The handle to the system image list.
    Dim fName As String      'The file name to get the icon from.
    Dim shinfo As SHFILEINFO
    shinfo = New SHFILEINFO()
    Dim openFileDialog1 As OpenFileDialog
    openFileDialog1 = New OpenFileDialog()
    
    openFileDialog1.InitialDirectory = "c:\temp\"
    openFileDialog1.Filter = "All files (*.*)|*.*"
    openFileDialog1.FilterIndex = 2
    openFileDialog1.RestoreDirectory = True
    
    listView1.SmallImageList = imageList1
    listView1.LargeImageList = ImageList1
    
    shinfo.szDisplayName = New String(Chr(0), 260)
    shinfo.szTypeName = New String(Chr(0), 80)
    
    If (openFileDialog1.ShowDialog() = DialogResult.OK) Then
         fName = openFileDialog1.FileName
    
         'Use this to get the small icon.
         hImgSmall = SHGetFileInfo(fName, 0, shinfo, Marshal.SizeOf(shinfo), _
             SHGFI_ICON Or SHGFI_SMALLICON)
    
         'Use this to get the large icon.
         'hImgLarge = SHGetFileInfo(fName, 0, 
         'ref shinfo, (uint)Marshal.SizeOf(shinfo), 
         'SHGFI_ICON | SHGFI_LARGEICON);
    
         'The icon is returned in the hIcon member of the shinfo struct.
         Dim myIcon As System.Drawing.Icon
         myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon)
    
         imageList1.Images.Add(myIcon) 'Add icon to imageList.
    
         listView1.Items.Add(fName, nIndex) 'Add file name and icon to listview.
         nIndex = nIndex + 1
    End If
    					

????? ?? ???????

  1. ????? ???????: ?? ??????? ????? ? ???? ??? ????? ????.
  2. ???? F5 ?????? ???????.
  3. ???? ??? ????? ??? ?? ?? ?????? ??? ?? ???? ?????? ???. ???? ??? ????? ? ????? ??????? ?? ????? ?? ???? ???? ListView.

?????

?????? ??? ??????? ?????? ?? ????? Microsoft Visual C# .NET ?? ??? ???????? ???? ??? ??? ??????? ????? ?????? ?? "????? ??????? ?? Microsoft:
319350????? ??????? ???? SHGetFileInfo ??? ????? ?????? ???? ????? ?? ??????? ?? Visual C# .NET

???????

???? ???????: 319340 - ????? ??? ??????: 18/????? ??????/1425 - ??????: 2.0
????? ???
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
????? ??????: 
kbmt kbhowtomaster KB319340 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????319340

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com