windows - Delphi 中的 Windows 10“固定启动”
问题描述
我正在尝试编写一个 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
解决方案
推荐阅读
- javascript - 如何验证表单中的多封电子邮件?
- javascript - 从 html input="date" 到 html 选择下拉格式
- python-3.x - 使用自定义简历在 Sklearn 中进行交叉验证
- html - 我的代码和命令中有 crud 问题
- php - 计算项目中方法的行数
- javascript - 如何从javascript返回多个值到jsp
- javascript - Trying to compare items in an array to see if they are the same
- mysql - "(" 在这个服务器版本的这个位置无效
- google-cloud-firestore - 如何在 Cloud Firestore 安全规则中实施写入速率限制?
- powershell - Test-WSMan 使用 powershell 失败