M
Mario
Hi dear programmer,
I'm trying to get associate file type descriptions; for instance "music.mp3"
should return "MP3 audio file (mp3)".
I'm using SHGetFileInfo:
Imports System.Runtime.InteropServices
Private Structure SHFILEINFO
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public
szDisplayName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public szTypeName
As String
End Structure
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
Const SHGFI_TYPENAME = &H400
Private Function GetAssociateType(ByVal sPath As String) As String
Dim hImgSmall As IntPtr
Dim shinfo As New SHFILEINFO
shinfo.szDisplayName = New String(Chr(0), 260)
shinfo.szTypeName = New String(Chr(0), 80)
hImgSmall = SHGetFileInfo(sPath, 0, shinfo, Marshal.SizeOf(shinfo), _
SHGFI_TYPENAME)
Return shinfo.szTypeName
End Function
This code is similar to the one I use to get the icons associated with
files:
VB: http://support.microsoft.com/default.aspx?scid=kb;EN-US;319340
C#: http://support.microsoft.com/default.aspx?scid=kb;EN-US;319350
The icons works fine, but what I wanted most (AssociateType) doesn't seams
to work :-(
I always get an empty string.
Please, please... help if you can, cause I'm realy stuck.
Kind regards,
Mario
I'm trying to get associate file type descriptions; for instance "music.mp3"
should return "MP3 audio file (mp3)".
I'm using SHGetFileInfo:
Imports System.Runtime.InteropServices
Private Structure SHFILEINFO
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public
szDisplayName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public szTypeName
As String
End Structure
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
Const SHGFI_TYPENAME = &H400
Private Function GetAssociateType(ByVal sPath As String) As String
Dim hImgSmall As IntPtr
Dim shinfo As New SHFILEINFO
shinfo.szDisplayName = New String(Chr(0), 260)
shinfo.szTypeName = New String(Chr(0), 80)
hImgSmall = SHGetFileInfo(sPath, 0, shinfo, Marshal.SizeOf(shinfo), _
SHGFI_TYPENAME)
Return shinfo.szTypeName
End Function
This code is similar to the one I use to get the icons associated with
files:
VB: http://support.microsoft.com/default.aspx?scid=kb;EN-US;319340
C#: http://support.microsoft.com/default.aspx?scid=kb;EN-US;319350
The icons works fine, but what I wanted most (AssociateType) doesn't seams
to work :-(
I always get an empty string.
Please, please... help if you can, cause I'm realy stuck.
Kind regards,
Mario