473,698 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get a folder icon?

yxq
Hello
I found a icon Class, i have tested the code, it can get file and drive
icons, but not folder icons,
How to get a folder icon?

Thanks
*************** *************** *************** *************** *************
'============== =============== =============== =============== =============== =
==========
' clsIcon
' class to work with icons
'============== =============== =============== =============== =============== =
==========
Imports System
Imports System.Drawing
Imports System.Runtime. InteropServices

Public Class clsIcon
'============== =============== =============== =============== =============== =
==========
' Enumerations

'============== =============== =============== =============== =============== =
==========
<Flags()> Private Enum SHGFI
SmallIcon = &H1
LargeIcon = &H0
Icon = &H100
DisplayName = &H200
Typename = &H400
SysIconIndex = &H4000
UseFileAttribut es = &H10
End Enum

Public Enum IconSize
SmallIcon = 1
LargeIcon = 0
End Enum
'============== =============== =============== =============== =============== =
==========
' Structures

'============== =============== =============== =============== =============== =
==========
<StructLayout(L ayoutKind.Seque ntial)> _
Private Structure SHFILEINFO
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As Integer
<MarshalAs(Unma nagedType.LPStr , SizeConst:=260) > Public szDisplayName As
String
<MarshalAs(Unma nagedType.LPStr , SizeConst:=80)> Public szTypeName As
String

Public Sub New(ByVal B As Boolean)
hIcon = IntPtr.Zero
iIcon = 0
dwAttributes = 0
szDisplayName = vbNullString
szTypeName = vbNullString
End Sub
End Structure
'============== =============== =============== =============== =============== =
==========
' API Calls

'============== =============== =============== =============== =============== =
==========
Private Declare Auto Function SHGetFileInfo Lib "shell32" (ByVal pszPath As
String, ByVal dwFileAttribute s As Integer, ByRef psfi As SHFILEINFO, ByVal
cbFileInfo As Integer, ByVal uFlagsn As SHGFI) As Integer
'============== =============== =============== =============== =============== =
==========
' Functions and Procedures...

'============== =============== =============== =============== =============== =
==========
Public Shared Function GetDefaultIcon( ByVal Path As String, Optional ByVal
IconSize As IconSize = IconSize.SmallI con, Optional ByVal SaveIconPath As
String = "") As Icon
Dim info As New SHFILEINFO(True )
Dim cbSizeInfo As Integer = Marshal.SizeOf( info)
Dim flags As SHGFI = SHGFI.Icon Or SHGFI.UseFileAt tributes
flags = flags + IconSize
SHGetFileInfo(P ath, 256, info, cbSizeInfo, flags)
GetDefaultIcon = Icon.FromHandle (info.hIcon)
If SaveIconPath <> "" Then
Dim FileStream As New IO.FileStream(S aveIconPath, IO.FileMode.Cre ate)
GetDefaultIcon. Save(FileStream )
FileStream.Clos e()
End If
End Function 'GetDefaultIcon (ByVal Path As String, Optional ByVal
IconSize As IconSize = IconSize.SmallI con, Optional ByVal SaveIconPath As
String = "") As Icon

'============== =============== =============== =============== =============== =
==========
Public Shared Function ImageToIcon(ByV al SourceImage As Image) As Icon
' converts an image into an icon
Dim TempBitmap As New Bitmap(SourceIm age)
ImageToIcon = Icon.FromHandle (TempBitmap.Get Hicon())
TempBitmap.Disp ose()
End Function 'ImageToIcon(By Val SourceImage As Image) As Icon

'============== =============== =============== =============== =============== =
==========

End Class

*************** *************** *************** *************** *************** *
*


Nov 20 '05 #1
4 14400
HEllo,

"yxq" <ga***@163.ne t> schrieb:
I found a icon Class, i have tested the code, it can get file and drive
icons, but not folder icons,
How to get a folder icon?


http://vbaccelerator.com/article.asp?id=4303

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
yxq
Thank you, but i know a little about C#, could you help me to convert the C#
code to VB.Net?
"Herfried K. Wagner [MVP]" <hi*******@m.ac tivevb.de> дÈëÏûÏ¢ÐÂÎÅ
:#S************ **@tk2msftngp13 .phx.gbl...
HEllo,

"yxq" <ga***@163.ne t> schrieb:
I found a icon Class, i have tested the code, it can get file and drive
icons, but not folder icons,
How to get a folder icon?


http://vbaccelerator.com/article.asp?id=4303

--
Herfried K. Wagner
MVP ?VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #3
searhc google
c# vb.net converter
"yxq" <ga***@163.ne t> wrote in message
news:#M******** ******@tk2msftn gp13.phx.gbl...
Thank you, but i know a little about C#, could you help me to convert the C# code to VB.Net?
"Herfried K. Wagner [MVP]" <hi*******@m.ac tivevb.de> дÈëÏûÏ¢ÐÂÎÅ
:#S************ **@tk2msftngp13 .phx.gbl...
HEllo,

"yxq" <ga***@163.ne t> schrieb:
I found a icon Class, i have tested the code, it can get file and drive icons, but not folder icons,
How to get a folder icon?


http://vbaccelerator.com/article.asp?id=4303

--
Herfried K. Wagner
MVP ?VB Classic, VB.NET
http://www.mvps.org/dotnet


Nov 20 '05 #4
Hello,

"yxq" <ga***@163.ne t> schrieb:
Thank you, but i know a little about C#, could you help me to
convert the C# code to VB.Net?


C# -> VB .NET Converters:

http://www.kamalpatel.net/ConvertCSharp2VB.aspx
http://csharpconverter.claritycon.com/Default.aspx
http://www.ragingsmurf.com/vbcsharpconverter.aspx
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

http://www.remotesoft.com/
-> "Octopus"

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5

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

Similar topics

13
7201
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be created if they don't already exist, and if the drive happens to be one a folder cannot be created on (ie a cdrom drive) it would just be skipped without the code generating any errors. your help on this would be most appreciated. jenny
0
912
by: Peter Schmitz | last post by:
Hi, is there any way to accomplish the following two tasks in .net code? - How can I change the icon for an existing folder? - How can I set the access permissions (e.g. only admin access) of the folder? Thanks a lot Peter
16
7407
by: Phil Hey | last post by:
Hi, I can change the icon for a folder by right clicking on it > going to the customize tab > and selecting Choose Picture. Does anyone know if it is possible to do this programmatically from a windows forms application?
3
4140
by: cj | last post by:
I found a good tutorial for making a windows setup program so I'm doing that. But when I add folders to the target machine list they don't seem to have one for the all users startup folder. I assume this will be a custom location and I added one called Startup. Now I'm looking at the properties menu for it but I'm not sure how to set the properties to specify the all users startup folder--if it exists, user startup if not.
1
2236
by: Jet Jaguar | last post by:
I'm trying to find a way to set a custom folder icon in OS X. I thought that Applescript would be able to do it, but apparently it can't. Is there anything in the Macintosh libraries of Python that will allow me to take an image file (e.g., jpeg, png, tiff, etc.) and set it as the icon for a folder? Kevin D. Smith
5
1300
by: al jones | last post by:
Normally I have some idea of where in the MSDN to start looking but on this one I have absolutely no idea. A fellow who uses my 'toy' asked if would be possible to drop a folder of files / folders to be processed onto the desktop icon ( well, of course it would ;) ) My question is how do I detect that in a vb 2005 program?? //al (( Cor, I'm working of the question .... ))
4
1670
by: mikkoO8 | last post by:
hi. im actually making a desktop cleaner that can move the files and icons to a folder inside the listview box. i can make the listview box filled with files contains at the desktop and i can make a new folder which suppose to be move the files on that folder i have 3 problems: 1. is how to get last access time of the FILE and put it column2 of the listview 2. i want to view that are unused icon and document last week, 2weeks, 1month...
14
12777
by: Ashutosh Bhawasinka | last post by:
Hi, How can I retrieve the system icon associated with a file/folder so that I can show it in the list view adjacent to the file/folder name? Regards, Ashutosh Bhawasinka
2
11402
HillComanchy
by: HillComanchy | last post by:
I have an old blackberry 8700c, I want to create a home screen icon that takes me directly to the SMS Inbox folder, or to a specific folder from my exchange mailbox, how do I do that? I found out that pressing alt with the wheel lets me move or delete an existing icon from the homescreen, but how do I add an entirely new one ? http://www.cebst.com/blackberry+8700c.jpg That's what it look like: http://www.cebst.com/blackberry+8700c.jpg
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.