X-Git-Url: http://git.sourceforge.jp/view?p=applistation%2FAppliStation.git;a=blobdiff_plain;f=na-get-lib%2FNaGet.InteropServices%2FShellLink.cs;h=12bf1eb0acbfe9c7a4f95bf9a737e31c5c62c06c;hp=f243c01216c14bed389742cbc5f07ba73e55a096;hb=09d2c09137c9c62127d0aea826bae12836b40a74;hpb=83a5af8064fd41874873b329abd3cf6ee8acdf1e
diff --git a/na-get-lib/NaGet.InteropServices/ShellLink.cs b/na-get-lib/NaGet.InteropServices/ShellLink.cs
index f243c01..12bf1eb 100644
--- a/na-get-lib/NaGet.InteropServices/ShellLink.cs
+++ b/na-get-lib/NaGet.InteropServices/ShellLink.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
@@ -100,12 +100,19 @@ namespace NaGet.InteropServices
protected const int MAX_PATH = 260;
+ ///
+ /// æ°ããã·ã§ã«ãªã³ã¯ãä½æããå½¢ã®ã³ã³ã¹ãã©ã¯ã¿
+ ///
public ShellLink()
{
Type shellLinkType = Type.GetTypeFromCLSID(new Guid(ShellLinkGuid));
shellLink = (IShellLinkW) Activator.CreateInstance(shellLinkType);
}
+ ///
+ /// æ¢åã®ã·ã§ã«ãªã³ã¯ãéãã³ã³ã¹ãã©ã¯ã¿
+ ///
+ /// æ¢åã®ã·ã§ã«ãªã³ã¯ã®ãã¹
public ShellLink(string path) : this()
{
if (! System.IO.File.Exists(path)) {
@@ -276,5 +283,32 @@ namespace NaGet.InteropServices
return shelllink;
}
+
+ ///
+ /// ã·ã§ã¼ãã«ããå
ã®EXEãã¡ã¤ã«ã«å¯¾ãã¦é©åãªååãçæããã
+ ///
+ /// å
·ä½çã«ã¯ãã¢ã»ã³ããªã®è£½ååãã¾ãåªå
çã«ä½¿ãã
+ /// ããããªããã°ãexeãã¡ã¤ã«ã®ãã¡ã¤ã«å(æ¡å¼µåãé¤ãããã®)ãè¿ãã
+ ///
+ /// æ¡å¼µåã¯ã¤ããªãã®ã§ãlnkãã¡ã¤ã«åã«ä½¿ãå ´åã¯ãæåã§
+ /// ".lnk"
ã追å ãããã¨ã
+ ///
+ /// æ¡å¼µåãå«ã¾ãªããé©åãªåå
+ public string GetSuitableShellLinkNameFor()
+ {
+ string exeFile = GetPath(0);
+
+ try {
+ FileVersionInfo vInfo = FileVersionInfo.GetVersionInfo(exeFile);
+ if (vInfo.ProductName != null && vInfo.ProductName != string.Empty
+ && vInfo.ProductName.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) < 0) {
+ // ååã製ååãæ¡ç¨
+ return vInfo.ProductName;
+ }
+ } catch (Exception) {}
+
+ // ãã®ã»ãã®å ´åã¯ã*.exeãã¡ã¤ã«ã®ååããã®ã¾ã¾ä½¿ç¨
+ return System.IO.Path.GetFileNameWithoutExtension(exeFile);
+ }
}
}