我的资源文件中有一个图标,我想引用它.
这是需要该图标文件路径的代码:
IWshRuntimeLibrary.IWshShortcut MyShortcut ;
MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\PerfectUpload.lnk");
MyShortcut.IconLocation = //path to icons path . Works if set to @"c:/icon.ico"
Run Code Online (Sandbox Code Playgroud)
我没有外部图标文件,而是希望它找到嵌入式图标文件.就像是
MyShortcut.IconLocation = Path.GetFullPath(global::perfectupload.Properties.Resources.finish_perfect1.ToString()) ;
Run Code Online (Sandbox Code Playgroud)
这可能吗 ?如果是这样的话?
谢谢
我认为它会在某些方面对您有所帮助...
//Get the assembly.
System.Reflection.Assembly CurrAssembly = System.Reflection.Assembly.LoadFrom(System.Windows.Forms.Application.ExecutablePath);
//Gets the image from Images Folder.
System.IO.Stream stream = CurrAssembly.GetManifestResourceStream("ImageURL");
if (null != stream)
{
//Fetch image from stream.
MyShortcut.IconLocation = System.Drawing.Image.FromStream(stream);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
29045 次 |
最近记录: |