Hi, in VB6 I use the following Declaration:

Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA"
(ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO,
ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long

Private Type SHFILEINFO

hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80

End Type

which I then call this way:

Call SHGetFileInfo(MyFile, 0, MyFI, Len(MyFI), SHGFI_ICON)

... and works. It retrieves a handle to the icon representing the file I
specify in MyFile and puts it in MyFI.hIcon so I can use it.

Now in VB.NET I use this syntax:

Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA"
(ByVal pszPath As String, ByVal dwFileAttributes As Integer, psfi As SHFILEINFO,
ByVal cbFileInfo As Integer, ByVal uFlags As Integer) As Integer

Private Struct SHFILEINFO

Public hIcon As Integer
Public iIcon As Integer
Public dwAttributes As Integer
Public szDisplayName As String
Public szTypeName As String

End Struct

' Initialize strings
MyFI.szDisplayName = New String(chr(0),260)
MyFI.szTypeName = New String(chr(0),80)
Call SHGetFileInfo(MyFile, 0, MyFI, Len(MyFI), SHGFI_ICON)

... and fails. Anybody know why?

Thank you.
Flavio Hualpa.