2016-06-21 17 views
1

Windowsのスタートメニューにショートカットを作成しようとしているアプリケーションがあります。スタートメニューのフォルダにショートカットを作成しています。 dll.Thisコードに存在している私のカスタムアイコンがWindows 7のではなく、窓10.Belowに働くと私のコード -Windows 10スタートメニューのカスタムフォルダアイコンが表示されない

using System; 
using System.IO; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 

using System.Threading.Tasks; 
using IWshRuntimeLibrary; 
using System.Diagnostics; 
using System.Reflection; 
using System.Drawing; 

namespace CreateDesktopShortCut 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string pathToExe = @"D:\Practice\folder\nipp.exe"; 
      string commonStartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); 
      string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); 
      string appStartMenuPath = Path.Combine(commonStartMenuPath, "Programs", "Custom_folder"); 
      if (!Directory.Exists(appStartMenuPath)) 
        Directory.CreateDirectory(appStartMenuPath); 
      setFolderIcon(appStartMenuPath,"my folder"); 
      string shortcutLocation = Path.Combine(appStartMenuPath, "Shortcut_to_Test_App" + ".lnk"); 
      WshShell shell = new WshShell(); 
      IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation); 
      shortcut.Description = "Test App Description"; 
      shortcut.TargetPath = pathToExe; 
      shortcut.Save(); 

      Console.WriteLine("Done"); 
      Console.ReadLine(); 
     } 

     public static void setFolderIcon(string path, string folderToolTip) 
     { 
      /* Remove any existing desktop.ini */ 
      if (System.IO.File.Exists(path + @"\desktop.ini")) System.IO.File.Delete(path + @"\desktop.ini"); 



      /* Write the desktop.ini */ 
      using (StreamWriter sw = System.IO.File.CreateText(path + @"\desktop.ini")) 
      { 
       sw.WriteLine("[.ShellClassInfo]"); 
       sw.WriteLine("InfoTip=" + folderToolTip); 
       sw.WriteLine("IconFile=" + @"C:\Program Files (x86)\blah\blah\abc.dll"); 
       sw.WriteLine("IconIndex=-101"); 
      } 


      /* Set the desktop.ini to be hidden */ 
      System.IO.File.SetAttributes(path + @"\desktop.ini", System.IO.File.GetAttributes(path + @"\desktop.ini") | FileAttributes.Hidden); 

      /* Set the path to system */ 
      System.IO.File.SetAttributes(path, System.IO.File.GetAttributes(path) | FileAttributes.System); 
     }   

    } 
} 

上記コードの問題である、それは正常に動作しているWindows 7です。スタートメニュー(C:/ users/appdata ../ StartMenu)の場所にあるウィンドウ10でさえ、カスタムアイコンで作成されています。しかし、スタートメニューの表示では、デフォルトのフォルダアイコンが表示されます。

答えて

0

私はこのトピックについてさらに調査を行い、Windows 10の[スタート]メニューにはデフォルトのアイコンしか表示されていないことがわかりました。しかし、フォルダがスタートメニューのタイルに固定されていれば、

関連する問題