Современные решения

для защиты Windows приложений

и восстановления исходного кода
Автор: Askhat Urazbaev. Дата публикации: 10.06.2004

Как запустить программу и дождаться выполнения



Option Explicit Const INFINITE = &HFFFF 'StartupInfo constants Public Const STARTF_FORCEOFFFEEDBACK = &H80 Public Const STARTF_FORCEONFEEDBACK = &H40 Public Const STARTF_RUNFULLSCREEN = &H20 Public Const STARTF_USECOUNTCHARS = &H8 Public Const STARTF_USEFILLATTRIBUTE = &H10 Public Const STARTF_USEPOSITION = &H4 Public Const STARTF_USESHOWWINDOW = &H1 Public Const STARTF_USESIZE = &H2 Public Const STARTF_USESTDHANDLES = &H100 'ShowWindow constants Public Const SW_HIDE = 0 Public Const SW_SHOWNORMAL = 1 Public Const SW_SHOWMINIMIZED = 2 Public Const SW_MAXIMIZE = 3 Public Const SW_SHOWMAXIMIZED = 3 Public Const SW_SHOWNOACTIVATE = 4 Public Const SW_SHOW = 5 Public Const SW_MINIMIZE = 6 Public Const SW_SHOWMINNOACTIVE = 7 Public Const SW_SHOWNA = 8 Public Const SW_RESTORE = 9 Public Const SW_SHOWDEFAULT = 10 Public Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Public 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 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 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Public Function RunAndWait(ComLine As String, DefaultDir As String, ShowFlag As VbAppWinStyle) As Boolean Dim si As STARTUPINFO Dim pi As PROCESS_INFORMATION si.wShowWindow = ShowFlag si.dwFlags = STARTF_USESHOWWINDOW If CreateProcess(vbNullString, ComLine, ByVal 0&, ByVal 0&, False, 0, ByVal 0&, DefaultDir, si, pi) Then WaitForSingleObject pi.hProcess, INFINITE CloseHandle pi.hProcess RunAndWait = True Exit Function End If RunAndWait = False End Function

Использование:

If RunAndWait("smth.exe", "c:\windows", vbNormalFocus) Then MsgBox "Registry backuped!" End If


Комментарии

отсутствуют

Добавление комментария


Ваше имя (на форуме):

Ваш пароль (на форуме):

Комментарии могут добавлять только пользователи,
зарегистрированные на форуме данного сайта. Если Вы не
зарегистрированы, то сначала зарегистрируйтесь тут

Комментарий: