Fixes for Mono
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
||||
@@ -13,20 +13,29 @@ namespace ImageCrusher
|
||||
private static bool CreateShortcut(string shortcut, string exe, string dir)
|
||||
{
|
||||
bool created = false;
|
||||
Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); //Windows Script Host Shell Object
|
||||
object shell = Activator.CreateInstance(t);
|
||||
Type shellType = null;
|
||||
object shell = null;
|
||||
try
|
||||
{
|
||||
object lnk = t.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, shell, new object[] { shortcut });
|
||||
shellType = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); //Windows Script Host Shell Object
|
||||
shell = Activator.CreateInstance(shellType);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return created;
|
||||
}
|
||||
try
|
||||
{
|
||||
string targetPath = (string)t.InvokeMember("TargetPath", BindingFlags.GetProperty, null, lnk, null);
|
||||
object lnk = shellType.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, shell, new object[] { shortcut });
|
||||
try
|
||||
{
|
||||
string targetPath = (string)shellType.InvokeMember("TargetPath", BindingFlags.GetProperty, null, lnk, null);
|
||||
if (targetPath != exe)
|
||||
{
|
||||
t.InvokeMember("TargetPath", BindingFlags.SetProperty, null, lnk, new object[] { exe });
|
||||
t.InvokeMember("WorkingDirectory", BindingFlags.SetProperty, null, lnk, new object[] { dir });
|
||||
t.InvokeMember("IconLocation", BindingFlags.SetProperty, null, lnk, new object[] { String.Format("{0}, 1", exe) });
|
||||
t.InvokeMember("Save", BindingFlags.InvokeMethod, null, lnk, null);
|
||||
shellType.InvokeMember("TargetPath", BindingFlags.SetProperty, null, lnk, new object[] { exe });
|
||||
shellType.InvokeMember("WorkingDirectory", BindingFlags.SetProperty, null, lnk, new object[] { dir });
|
||||
shellType.InvokeMember("IconLocation", BindingFlags.SetProperty, null, lnk, new object[] { String.Format("{0}, 1", exe) });
|
||||
shellType.InvokeMember("Save", BindingFlags.InvokeMethod, null, lnk, null);
|
||||
created = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user