delphi中的windows10“pintostart”

delphi中的windows10“pintostart”,windows,shell,delphi,execute,Windows,Shell,Delphi,Execute,我正在尝试编写一个delphi应用程序,自动将应用程序固定到“开始”菜单,以便在平板电脑模式下很容易看到它们 我做了一些研究,发现了一个可以工作的VBScript,请参见下面的代码 因此,我尝试用Shell Execute在我的delphi应用程序中打开VBScript ShellExecute(Handle, 'open', Pchar('C:\tmp\VBScript.vbs'), 'C:\WINDOWS\system32\ notepad.exe', nil, SW_NORMAL); 但

我正在尝试编写一个delphi应用程序,自动将应用程序固定到“开始”菜单,以便在平板电脑模式下很容易看到它们

我做了一些研究,发现了一个可以工作的VBScript,请参见下面的代码

因此,我尝试用Shell Execute在我的delphi应用程序中打开VBScript

ShellExecute(Handle, 'open', Pchar('C:\tmp\VBScript.vbs'), 'C:\WINDOWS\system32\ notepad.exe', nil, SW_NORMAL);
但是,如果我尝试使用shell execute运行脚本,则没有Pin-to-start动词。否则,如果我直接从资源管理器打开它,它就会工作

直接从windows资源管理器或使用shell execute从delphi运行文件有什么区别

或者你有没有办法让我只使用delphi来锁定应用程序

VBScript:

Dim Argumente
Dim File, objFSO
Dim strFolder, strExecutable

Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
arg0 = wscript.arguments.unnamed.item("0")
arg1 = wscript.arguments.unnamed.item("1")

File = arg0&arg1

If (objFSO.FileExists(File )) Then 
Else
WScript.Echo "File " & File & " gibt es nicht. Script fehlgeschlagen"
WScript.Quit(2)
End If

strFolder = arg0
strExecutable = arg1

WScript.Echo "Folder:" & strFolder & ""
WScript.Echo "File:" & strExecutable & ""

Set objFolder = objShell.Namespace(strFolder)
Set objFolderItem = objFolder.ParseName(strExecutable)

Set colVerbs = objFolderItem.Verbs

'uncomment this section to display the available verbs
 For Each objVerb In colVerbs
    If objVerb <> "" Then
       WScript.Echo objVerb
    End If
 Next

'Loop through the verbs and if PIN is found then 'DoIt' (execute)
blnOptionFound = False
For Each objVerb In colVerbs
   If Replace(objVerb.name, "&", "") = "Pin to Start" Then
      objVerb.DoIt
      blnOptionFound = True
      WScript.Echo "The application '" & strExecutable & "' was just Pinned to the Start Menu."
      WScript.Quit(0)   
End If
Next

if blnOptionFound = false then
   WScript.Echo "The application '" & strExecutable & "' was already pinned to the Start Menu."
   WScript.Quit(1)   
end if

有一个用于固定“开始”菜单项的特殊文件夹,您只需在其中放置程序的快捷方式


因此,无需为此使用复杂的scipts

该脚本基本上相当于查询文件的IContextMenu界面,检索其弹出菜单,在其中循环,并调用特定的itemyes,但是,当我尝试在delphi应用程序中使用shellexecute运行脚本时,为什么会有不同的项目?不同的执行环境、不同的上下文、不同的可用选项。另外,因为脚本中有一个错误-如果objFSO.FileExistsFile,那么应该是objFSO.FileExistsFile,如果不是objFSO.FileExistsFile,那么如果您的程序非常棒,那么用户可能会选择锁定它。但这不是用户的选择吗。我讨厌一个为我做出这个决定的程序。@DavidHeffernan它是为了工作,所以安装它不是用户的选择……而且对于普通用户来说,导航到C:\programfiles\。。。。在平板电脑模式下锁定它。您好SilverWarrior,谢谢您的回答,但是Win10 1709中的此文件夹中没有快捷方式请参阅该帖子中的各种注释。微软在Windows10中改变了一切。微软不希望人们以编程的方式固定东西,固定应该是一种用户专用的操作。