473,320 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How extract associated icon

Hello all!
How can i exract an icon associated with a file?
I found API function ExtractAssociatedIcon, but can i use
this function with VB.Net?
Can i do it easier with some .Net class?

Thanks.
Nov 20 '05 #1
2 7285
Hi,
You can use the ExtractAssociatedIcon API in VB.net to get a handle to an
icon. Here is how you should declare it in VB.net.

Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias
"ExtractAssociatedIconA" (ByVal hInst As IntPtr, ByVal lpIconPath As
String, ByRef lpiIcon As Integer) As IntPtr

You need to use the IntPtr data type whenver a handle is expected in a API.
Also instead of long, use the Integer data type.

You can call the API as follows
Dim y as IntPtr

y = ExtractAssociatedIcon(Process.GetCurrentProcess(). Handle, "c:\program
files\microsoft office\office10\excel.exe", 1)
Once you get the handle, you can use it in other API's and also you can
check you the System.Drawing.Icon class.

Hope this helps.
Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks

Nov 20 '05 #2
Anand,
y = ExtractAssociatedIcon(Process.GetCurrentProcess(). Handle, "c:\program
files\microsoft office\office10\excel.exe", 1)


Process.GetCurrentProcess().Handle returns a process handle, not a
HINSTANCE which is what ExtractAssociatedIcon expects. You probably
want to use Marshal.GetHINSTANCE instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve | last post by:
How can I extract a icon from a exist program? for examle, notepad.exe.
7
by: Shane Story | last post by:
I want to be able to get the icon associated with a certain file extension. I can read the registry hkey_classes to get the ext. then look to the other key for default icon. How can I then...
3
by: Brian Henry | last post by:
How would you get the associated icon for the file type of a file with a certain extension? like BMP, JPEG, MPEG, etc etc find their default icon using the File Types listing that associates the...
4
by: Giovanni pepe | last post by:
I have download from site Microsoft the procedure for Get Associated Icon from File Article is : "How to use the SHGetFileInfo function to get the icons that are associated with files in Visual...
5
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
6
by: Udi | last post by:
Hi, I have an imagelist initialized in design time with several icons files (.ico). However, when I need to extract an icon (Image) from the Imagelist, I can't convert it back to an icon: ...
4
by: techspirit | last post by:
Hi all, 1) I found out from the vb.net group that it is possible to get an associated icon for a file. My requirement is to display all programs from the Start Menu for the user along with the...
0
by: Mark | last post by:
Hi I tried to find a solution to this a while back and more surfing today has yielded nothing usefull. I am using "extractAssociatedIcon" to get icons for a listview containing files etc....
1
by: gevald123 | last post by:
I'm storing system files in a sql server database, as "image" datatype fields. In my front end (vb .net 1.1) I'd like to display these files in a listview with the "Windows Explorer" feel and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.