问题描述
我对VB .NET和一般的编程都很陌生,我想
给我的程序自己的图标而不是一个单独的文件。我将
图标作为项目的一部分,其Build Action设置为
Embedded Resource。我已经搜索了高低的代码,它将实际上将它作为程序的默认图标加载,但是我没有找到b $ b找到的代码。有人可以给我这么做的代码吗?
I''m fairly new to VB .NET and programming in general, and I want to
give my program its own icon without it being a separate file. I have
the icon as part of the project, and its Build Action is set to
Embedded Resource. I''ve searched high and low for the code that will
actually make it load as the program''s default icon, but nothing I''ve
found works. Can someone give me the code necessary to do this?
推荐答案
这里你是
''''''<摘要>
'''''从嵌入资源中读取图标
'''''< / summary>
公共共享函数readResourceIcon(ByVal IconName As String)As
Icon
''获取我们的程序集。
Dim execution_assembly As System.Reflection.Assembly = _
fMain.GetType.Assembly.GetEntryAssembly()
Dim picture_stream As Stream
Dim iconReaded As Icon
picture_stream =
execution_assembly.GetManifestResourceStream(IconN ame)
如果不是(picture_stream什么都没有)那么
iconReaded =新图标(picture_stream)
picture_stream.Close()
返回iconReaded
结束如果
结束功能
我希望这有帮助
Mario
here you are
''''''<summary>
'''''' Reads icon from embeded resource
'''''' </summary>
Public Shared Function readResourceIcon(ByVal IconName As String) As
Icon
'' Get our assembly.
Dim executing_assembly As System.Reflection.Assembly = _
fMain.GetType.Assembly.GetEntryAssembly()
Dim picture_stream As Stream
Dim iconReaded As Icon
picture_stream =
executing_assembly.GetManifestResourceStream(IconN ame)
If Not (picture_stream Is Nothing) Then
iconReaded = New Icon(picture_stream)
picture_stream.Close()
Return iconReaded
End If
End Function
I hope this helps
Mario
这篇关于图标作为嵌入式资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!