Hello Friends
well this is my first post on this site, hope i get the solution for my problem
During the development of one project i am facing this problem
i use a SHGetFileInfo structure to get icons for files and folders, it work fine but in same program i use SHGetFileInfo again to get a file type as it is display in windows explorer. this time i make a vb class file and call it whenever i req. to display a file type, but it shows some file type correctly and for certain files it display blank like .zip, .dll etc.
here is my vb class file
Imports System.Runtime.InteropServices
Public Class filetype
Private Declare Auto 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
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Private Structure SHFILEINFO
Public hIcon As Int32
Public iIcon As Int32
Public dwAttributes As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
Public szDisplayName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> _
Public szTypeName As String
End Structure
Private Const SHGFI_TYPENAME As Int32 = &H400
Public Function getfiletype(ByVal fname As String) As String
Dim x As SHFILEINFO
Dim type As String
SHGetFileInfo(fname.ToString, 0, x, Len(x), SHGFI_TYPENAME)
type = x.szTypeName.ToString
Return type
End Function
End Class
Try to solve my problem
Thanks