我正在尝试编写一个将应用程序自动固定到开始菜单的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
答案 0 :(得分:1)