Hola qtal,
Alguien sabe si se puede abrir una aplicación desde Visual Basic
Por ejemplo, hacer un botón que al pulsarlo te abra el Photoshop o cualquier otra aplicación
Un saludo y gracias
| |||
Abrir aplicación desde Visual Basic Hola qtal, Alguien sabe si se puede abrir una aplicación desde Visual Basic Por ejemplo, hacer un botón que al pulsarlo te abra el Photoshop o cualquier otra aplicación Un saludo y gracias |
| ||||
ejemplos tomados de www.allapi.net Ejemplo 1 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 Const SW_SHOWNORMAL = 1 Private Sub Form_Load() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: [email protected] 'Send an E-Mail to the KPD-Team ShellExecute Me.hwnd, vbNullString, "mailto:[email protected]", vbNullString, "C:\", SW_SHOWNORMAL End Sub ***************** ejemplo 2 'Example by Joel ([email protected]) 'This example requires a command button (Command1) Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long 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 Const SW_SHOWNORMAL = 1 Const SE_ERR_NOASSOC = 31 Const sOperation As String = "open" ' Constants for shell operations Const sRun As String = "RUNDLL32.EXE" Const sParameters As String = "shell32.dll,OpenAs_RunDLL " Private Function shelldoc(sfile As String) Dim sPath As String, RetVal As Long, _ lRet As Long lRet = ShellExecute(GetDesktopWindow(), sOperation, sfile, _ vbNullString, vbNullString, SW_SHOWNORMAL) If lRet = SE_ERR_NOASSOC Then ' No association exists 'Create a buffer sPath = Space(255) 'Get the system directory RetVal = GetSystemDirectory(sPath, 255) 'Remove all unnecessary chr$(0)'s 'and move on the stack sPath = Left$(sPath, RetVal) lRet = ShellExecute(GetDesktopWindow(), "open", sRun, _ sParameters + sfile, sPath, SW_SHOWNORMAL) End If End Function Private Sub Command1_Click() ' Change the file extensions so that one ' has a program associated with it and the ' other does not. Call shelldoc("C:\myfile.txt") Call shelldoc("C:\myfile.sarsaparilla") End Sub |
| |||
Shell (Función) ------------------- Ejecuta un programa ejecutable y devuelve un tipo Variant (Double) que representa la identificación de la tarea del programa si se ha ejecutado con éxito, en caso contrario devuelve cero. Ejemplo de la función Shell ----------------------------------- En este ejemplo se utiliza la función Shell para ejecutar una aplicación especificada por el usuario. ' Si se especifica 1 como el segundo argumento, la aplicación se ' ejecuta normalmente y recibe el enfoque. Dim RetVal RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Ejecuta Calculadora. |
| ||||
Yo tenia un programa cojonudo, lo que pasa que lo perdi. Pero funcionaba con teclas. Por ej. le daba a la tecla "i" y me abria el internet explorer. Lo hacia con el shell, con un if, si pulsa este bonton entonces shell("c:/windows/notepad.exe"). Un saludo ![]()
__________________ Pïno Webmaster de Programas Lynx Usuario Registrado de Linux #327681 Mi cuerpo en windows, pero mi mente pensando en linux. |