我想运行我的设置" d:\ myapp_setup_update.exe",因为我从服务运行它,我正在尝试使用CreateProcessAsUsers。
但是,我想我可能会弄错语法。 在运行此代码之前,我已确保路径存在且hToken不是0。
这是我目前的做法。
有人发现任何错误吗? 我甚至不确定API声明。 MSDN在某些示例中使用long,然后再使用字符串。真奇怪。
非常感谢您的帮助!
Private Declare Function CreateProcessAsUser Lib "advapi32.dll" _
Alias "CreateProcessAsUserA" _
(ByVal hToken As Long, _
ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
ByVal lpProcessAttributes As Long, _
ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, _
ByVal lpCurrentDirectory As String, _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Function pDoIt(ByVal hToken As Long) As Boolean
Dim sChildProcName$
sChildProcName = "d:\myapp_setup_update.exe"
Dim tProcessInfo As PROCESS_INFORMATION
Dim tStartupinfo As STARTUPINFO
tStartupinfo.cb = Len(tStartupinfo)
Dim bChildProcStarted As Boolean
bChildProcStarted = CreateProcessAsUser(hToken, sChildProcName, vbNullString, 0&, 0&, 0, 0&, 0, vbNullString, tStartupInfo, tProcessInfo)
'GetLastError always returns 0... strange
pDoIt = bChildProcStarted
End Sub
答案 0 :(得分:0)
知道了。我想要运行的应用程序应该表示为“lpCommandLine”arg。