我已经在.NET中创建了一个项目,并在Visual Studio 2017中获得了常见错误,就像上面的标题一样。
我一直在寻找不同的解决方案,但没有任何效果,所以我决定在这里提问,所以也许你能帮助我。
代码:
namespace MSBuilderTx
{
using IWshRuntimeLibrary;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management;
using System.Net;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
internal class Program
{
private const int MAXTITLE = 0xff;
private static ArrayList mTitlesList;
private static Regex rgx = new Regex("[^a-zA-Z0-9 -]");
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;
[DllImport("user32.dll", EntryPoint="EnumDesktopWindows",
CharSet=CharSet.Auto, SetLastError=true)]
private static extern bool _EnumDesktopWindows(IntPtr
hDesktop, EnumDelegate lpEnumCallbackFunction, IntPtr lParam);
[DllImport("user32.dll", EntryPoint="GetWindowText",
CharSet=CharSet.Auto, SetLastError=true)]
private static extern int _GetWindowText(IntPtr hWnd,
StringBuilder lpWindowText, int nMaxCount);
public static void CreateShortcut(string shortcutName, string
shortcutPath, string targetFileLocation)
{
string pathLink = Path.Combine(shortcutPath, shortcutName
+ ".lnk");
WshShell shell = (WshShell)
Activator.CreateInstance(Marshal.GetTypeFromCLSID(new
Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")));
IWshShortcut shortcut = (IWshShortcut)
shell.CreateShortcut(pathLink);
shortcut.Description = "Pixie Shortcut";
shortcut.TargetPath = targetFileLocation;
shortcut.Save();
}
行
WshShell shell = (WshShell)
Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("72C24DD5-
D70A-438B-8A42-98424B88AFB8")));
给出错误信息。