我正在尝试编写一个 delphi 应用程序,该应用程序自动将应用程序固定到开始菜单,因此它们在平板电脑模式下很容易看到。
我做了一些研究,发现的只是一个有效的 VBScript(见下面的代码)。
所以我尝试使用 Shell Execute 在我的 delphi 应用程序中打开 VBScript
ShellExecute(Handle, 'open', Pchar('C:\tmp\VBScript.vbs'), 'C:\WINDOWS\system32\ notepad.exe', nil, SW_NORMAL);
但是,如果我尝试使用 shell 运行脚本执行,则没有“Pin to start”动词。否则,如果我直接从资源管理器中打开它,它就可以工作。
直接从 windows 资源管理器运行文件或从 delphi 运行文件与 shell 执行有什么区别?
或者您知道如何尝试仅使用 delphi 固定应用程序吗?
VB脚本:
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