|
-
API call in VB.NET
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks