![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
11/11/2003, 09:55
|
| | Fecha de Ingreso: noviembre-2003
Mensajes: 4
Antigüedad: 21 años, 3 meses Puntos: 0 | |
Hola, la verdad es que hay un monton de formas, te comento algunas...
PRIMERA:
Decaraciones necesarias:
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
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Private Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, _
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 Long, lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
'************************************************* *************************************************
Luego te creas un pequeño procedimiento como este y ya esta.
Public Sub ExecuteAndWait(cmdLine As String, Esperar As Boolean)
Dim NameOfProc As PROCESS_INFORMATION
Dim NameStart As STARTUPINFO
Dim x As Long
NameStart.cb = Len(NameStart)
x = CreateProcessA(0&, cmdLine$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, NameStart, NameOfProc)
If Esperar Then
x = WaitForSingleObject(NameOfProc.hProcess, INFINITE)
x = CloseHandle(NameOfProc.hProcess)
End If
End Sub
########################################
SEGUNDA:
En esta necesitas un formulario como parametro
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'************************************************* *************************************************
Public Sub Execute(frmFormulario As Variant, cmdLine As String)
Dim ret As Long
ret = ShellExecute(frmFormulario.hwnd, "open", cmdLine, "", "", 1)
End Sub
########################################
TERCERA:
Tambien puedes usar el método shell, esto te permite abrir archivos, incluso accesos directos.
ret = Shell("start " & Chr(34) & cmdLine & Chr(34), vbMinimizedNoFocus)
Un saludo. |