como puedo ejecutar un programa exe desde visual con un boton
hola amigos mi problema es el siguiente tengo un programa echo en turbo c y tengo el ejecutable .exe
y lo ke kiero hacer es ke mediante un comand button al hacer click ejecute este programa gracias..
acepto cualkier ayuda
y lo ke kiero hacer es ke mediante un comand button al hacer click ejecute este programa gracias..
acepto cualkier ayuda
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()
Dim nombrePrograma As String
Dim rutaArchivo As String
nombrePrograma = "miPrograma.exe"
rutaArchivo = "C:ProgramasEjecutables"
ShellExecute Me.hwnd, vbNullString, "nombrePrograma", vbNullString, "rutaArchivo", SW_SHOWNORMAL
End Sub
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
Dim nombrePrograma As String
Dim rutaArchivo As String
nombrePrograma = "miPrograma.exe"
rutaArchivo = "C:ProgramasEjecutables"
ShellExecute Me.hwnd, vbNullString, "nombrePrograma", vbNullString, "rutaArchivo", SW_SHOWNORMAL
End Sub
Crea un formulario y ponle dos botones.
A帽ade el c贸digo siguiente:
Const REG_SZ = 1
Const REG_BINARY = 3
Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub Command1_Click()
SaveString HKEY_LOCAL_MACHINE, "SoftwareMicrosoftWindowsCurrentVersionRun", "Recetas", "c:RecetasRecetas.exe"
End Sub
Private Sub Command2_Click()
DelSetting HKEY_LOCAL_MACHINE, "SoftwareMicrosoftWindowsCurrentVersionRun", "Recetas"
End Sub
Private Sub Form_Load()
Command1.Caption = "PONER RECETAS"
Command2.Caption = "QUITAR RECETAS"
End Sub
Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
Dim Ret
RegCreateKey hKey, strPath, Ret
RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
RegCloseKey Ret
End Sub
Sub DelSetting(hKey As Long, strPath As String, strValue As String)
Dim Ret
RegCreateKey hKey, strPath, Ret
RegDeleteValue Ret, strValue
RegCloseKey Ret
End Sub
Ya est谩. S贸lo tienes que cambiar el nombre de programa cada vez o que tire de alg煤n cuadro de texto que lo indique. No olvides el Path.
A帽ade el c贸digo siguiente:
Const REG_SZ = 1
Const REG_BINARY = 3
Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub Command1_Click()
SaveString HKEY_LOCAL_MACHINE, "SoftwareMicrosoftWindowsCurrentVersionRun", "Recetas", "c:RecetasRecetas.exe"
End Sub
Private Sub Command2_Click()
DelSetting HKEY_LOCAL_MACHINE, "SoftwareMicrosoftWindowsCurrentVersionRun", "Recetas"
End Sub
Private Sub Form_Load()
Command1.Caption = "PONER RECETAS"
Command2.Caption = "QUITAR RECETAS"
End Sub
Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
Dim Ret
RegCreateKey hKey, strPath, Ret
RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
RegCloseKey Ret
End Sub
Sub DelSetting(hKey As Long, strPath As String, strValue As String)
Dim Ret
RegCreateKey hKey, strPath, Ret
RegDeleteValue Ret, strValue
RegCloseKey Ret
End Sub
Ya est谩. S贸lo tienes que cambiar el nombre de programa cada vez o que tire de alg煤n cuadro de texto que lo indique. No olvides el Path.
