2008-09-23 52 views
-1

我有一個在Vista上運行的傳統VB6可執行文件。這個可執行文件釋放出另一箇舊的MFC C++可執行文件Vista不允許一個.exe調用另一個.exe

在我們早期的Vista測試中,此調用將顯示典型的UAC消息,以在運行第二個可執行文件之前獲得用戶的許可。這並不完美,但可以接受。但是,現在看起來這個調用正被操作系統完全忽略。

我可以做些什麼來使這個電話工作?

+0

你能不能給多一點的上下文的問題一些很好的討論?這兩個應用程序做什麼? 我會提前注意到,如果你想讓vb6應用程序與C++應用程序「交談」,它將無法執行。由於C++作爲管理員運行。 – Nidonocu 2008-09-23 04:35:37

+0

沒有通信。試圖讓一個跑另一個,並傳遞一些參數。它們都安裝到程序文件下的同一目錄下,並在應用程序數據下訪問文件。 – JKueck 2008-09-23 06:40:04

回答

3

如果在機器上禁用了UAC,並且調用需要提升的權限,則對CreateProcess的調用將失敗。確保UAC已啓用。

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

+0

嗯..所以從另一個調用一個exe需要管理員權限?這似乎有點極端,考慮到不需要管理員權限來獨立運行。謝謝您的幫助。 – JKueck 2008-09-23 05:31:32

1

還有的問題和源的例子here.

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 
相關問題