Vista不允许一个.exe调用另一个.exe

时间:2008-09-23 04:32:05

标签: vb6 windows-vista executable shellexecute

我有一个在Vista上运行的遗留VB6可执行文件。这个可执行文件会弹出另一个传统的MFC C ++可执行文件。

在我们早期的Vista测试中,此调用将显示典型的UAC消息,以在运行第二个可执行文件之前获得用户的许可。这不完美,但可以接受。但是,现在看起来操作系统完全忽略了这个调用。

如何才能使此通话有效?

3 个答案:

答案 0 :(得分:4)

如果在计算机上禁用了UAC,并且该调用需要提升权限,则对CreateProcess的调用将失败。确保启用了UAC。

此外,请遵循指南here for adding a UAC manifest to your program

答案 1 :(得分:1)

对问题和来源示例here.

也有一些很好的讨论

答案 2 :(得分:0)

这在Vista下适合我们

Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Type PROCESS_INFORMATION
      hProcess As Long
      hThread As Long
      dwProcessId As Long
      dwThreadId As Long
End Type

Private Type STARTUPINFO
      cb As Long
      lpReserved As String
      lpDesktop As String
      lpTitle As String
      dwX As Long
      dwY As Long
      dwXSize As Long
      dwYSize As Long
      dwXCountChars As Long
      dwYCountChars As Long
      dwFillAttribute As Long
      dwFlags As Long
      wShowWindow As Integer
      cbReserved2 As Integer
      lpReserved2 As Long
      hStdInput As Long
      hStdOutput As Long
      hStdError As Long
End Type

    Dim ProcessInformation As PROCESS_INFORMATION
    Dim StartupInformation As STARTUPINFO
    Dim ReturnValue As Long
    Dim NullString As String
    Dim AppPathString As String

    StartupInformation.cb = Len(StartupInformation)

    ReturnValue = CreateProcess(NullString, AppPathString, ByVal 0&, ByVal 0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, NullString, StartupInformation, ProcessInformation)
    '
    'If you need to wait for the exe to finish
    '
    Do While WaitForSingleObject(ProcessInformation.hProcess, 0) <> 0
        DoEvents
    Loop
相关问题