回答編集履歴

1

追記

2017/03/06 06:58

投稿

YAmaGNZ
YAmaGNZ

スコア10258

test CHANGED
@@ -1,3 +1,79 @@
1
1
  [Windowsフォルダアイコンの変更](http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=31235&forum=7)
2
2
 
3
3
  このような情報がありました。
4
+
5
+
6
+
7
+
8
+
9
+ ・追記
10
+
11
+
12
+
13
+ リンク先のコードを試してみました。
14
+
15
+ ```C#
16
+
17
+ public class SetFolderIcon
18
+
19
+ {
20
+
21
+ [DllImport("kernel32.dll")]
22
+
23
+ private static extern bool WritePrivateProfileString(
24
+
25
+ string lpAppName, string lpKeyName
26
+
27
+ , string lpString, string lpFileName);
28
+
29
+ [DllImport("shlwapi.dll")]
30
+
31
+ private static extern bool PathMakeSystemFolder(
32
+
33
+ string folderName);
34
+
35
+
36
+
37
+ private SetFolderIcon()
38
+
39
+ {
40
+
41
+ }
42
+
43
+
44
+
45
+ public static void SetIcon(string targetFolder, string iconFilePath, int iconIndex)
46
+
47
+ {
48
+
49
+ string desktopIni = System.IO.Path.Combine(targetFolder, "Desktop.ini");
50
+
51
+ WritePrivateProfileString(".ShellClassInfo", "IconFile", iconFilePath, desktopIni);
52
+
53
+ WritePrivateProfileString(".ShellClassInfo", "IconIndex", iconIndex.ToString(), desktopIni);
54
+
55
+ System.IO.FileInfo finfo = new System.IO.FileInfo(desktopIni);
56
+
57
+ finfo.Attributes |= System.IO.FileAttributes.Hidden;
58
+
59
+ PathMakeSystemFolder(targetFolder);
60
+
61
+ }
62
+
63
+ }
64
+
65
+
66
+
67
+ ```
68
+
69
+ として
70
+
71
+ ```C#
72
+
73
+ SetFolderIcon.SetIcon(フォルダパス, アイコンファイル名, 0);
74
+
75
+ ```
76
+
77
+ としたところアイコンは変更されました。
78
+
79
+