EJECUTAR UN .EXE

EJECUTAR UN .EXE

Postby Claudio Leiva » Fri Mar 24, 2017 12:42 pm

será posible ejecutar un .exe desde la mdi principal de mi aplicacion,
se que con winexec se puede.. pero lo que ando buscando es que este .exe sea parte de la ventana principal o de una hija o de un dialog.. que no pueda escapar de su tamaño
no se si me explique bien?

saludos

sigo dando vuelta al tema
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm

Re: EJECUTAR UN .EXE

Postby Claudio Leiva » Fri Mar 24, 2017 3:38 pm

alguien lo habrá logrado
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm

Re: EJECUTAR UN .EXE

Postby Antonio Linares » Fri Mar 24, 2017 4:49 pm

Puedes hacer que la ventana del EXE ejecutado se convierta en hija de otra ventana (de otro EXE), usando la función SetParent():

https://msdn.microsoft.com/es-es/library/windows/desktop/ms633541(v=vs.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: EJECUTAR UN .EXE

Postby Claudio Leiva » Fri Mar 24, 2017 8:41 pm

estimado foro,, lo que necesito es algo como esto hecho en VB
http://www.recursosvisualbasic.com.ar/h ... urebox.htm

no doy los tiros
:roll: :roll:
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm

Re: EJECUTAR UN .EXE

Postby karinha » Fri Mar 24, 2017 8:53 pm

Code: Select all  Expand view

/*
   - autor: wmormar, INCOS -  wmormar@hotmail.com
   - fecha: 31 . octubre . 2008
   - hora: 03.11
*/


#include "fivewin.ch"

FUNCTION main()
   LOCAL oBmp
   LOCAL tCalc32
   //LOCAL this   := Self
   LOCAL lSalir := .f.

   /*
   IF ::oCalculator:classname() == "TDIALOG"
      ::oCalculator:restore()
      ::oCalculator:setfocus()
      RETURN NIL
   ENDIF
   */


   tCalc32 := TCalculator()
   DEFINE DIALOG ::oCalculator RESOURCE "CALCULADORA" TITLE ".:: Calculadora ::." COLOR CLR_BLUE,CLR_WHITE
      REDEFINE BITMAP oBmp ID 401 OF ::oCalculator TRANSPARENT
      ::oCalculator:bLDblClick := {|| tCalc32:cerrar_programa(), lSalir := .t., ::oCalculator:END(), ::oCalculator := NIL}
      ::oCalculator:bRClicked  := {|| tCalc32:incrustar_calculadora( oBmp )}

   ACTIVATE DIALOG ::oCalculator

   /*
    ON INIT equis(this:oCalculator:hWnd) ;
            VALID lSalir */


RETURN NIL

///////////////////////////////////////////////////////////////////////////////

/*
   Tomado: Recursos visualbasic
   Fecha:  31 . octubre . 2008
   Hora:   02.48

   INCOS, wmormar
*/


#include "fivewin.ch"
#include "CStruct.ch"
#include "wintypes.ch"

   // Constante para la llamada dinámica del API
#define DC_CALL_STD            0x0020

#define SHOWMAXIMIZED_eSW      3
   // Constante para usar con el Api DeleteMenu
#define MF_BYPOSITION          0x400
#define MF_REMOVE              0x1000

   // Constante para usar con el Api SendMessage para cerrar
   // la aplicación ( en este caso La calculadora )
#define SC_CLOSE              61536
#define WM_SYSCOMMAND         274

   // Constante para usar con GetWindowLong y SetWindowLong
#define GWL_STYLE             -16

   // Constantes para SetWindowPos
#define SWP_FRAMECHANGED      0x0020
#define SWP_NOMOVE            0x0002
#define SWP_NOSIZE            0x0001
#define SWP_NOZORDER          0x0004
#define HWND_TOP              0

CLASS TCalculator
   // Mantiene el Handle del programa
   DATA hwnd
   DATA hwndcalc
   DATA cTitlecalculator     AS CHARACTER  INIT  "Calculadora"
   DATA ocontainer           AS OBJECT
   DATA nTime                AS NUMERIC    INIT 25000

   METHOD normal()
   METHOD barra_titulo( lErase )
   METHOD Eliminar_Menu( hwnd )
   METHOD Cerrar_Programa( hwnd )
   METHOD Cerrar_Programa( hwnd )
   METHOD incrustar_calculadora( ocontainer )
   METHOD Incrustar( hwnd )
   METHOD liberar_programa( hwnd )
   METHOD GetMenu( hwnd )
   METHOD DeleteMenu( hmenu, nposition, wflags )
   METHOD GetMenuItemCount( hmenu )
   METHOD DrawMenuBar( hwnd )
   METHOD GetWindowLong( hwnd, nindex )
   METHOD SetWindowLong( hwnd, nindex, dwnewlong )
   METHOD SetWindowPos( hwnd, hwndinsertafter, x, y, cx, cy, wflags )

ENDCLASS

/*******************************************************************/
// Cargando calculadora normal de windows
METHOD normal()
   ShellExecute( ::hwnd,,"calc.exe",,, )

   RETURN NIL

/*******************************************************************/
// Elimina y reestablece la barra de título de una ventana
METHOD barra_titulo( hwnd, lErase )
   LOCAL nStyle

   // Almacena en la variable el estilo actual
   nStyle := ::GetWindowLong( hwnd, GWL_STYLE )

   IF !lErase
      nStyle := nor( nStyle, WS_CAPTION )
   ELSE
      nStyle += nor( WS_CAPTION )
   ENDIF

   // Aplica el nuevo estilo
   ::SetWindowLong( hwnd, GWL_STYLE, nStyle )

   // Mueve de posición la calculadora
   ::SetWindowPos( ::hwndcalc, HWND_TOP, 0, 0, 0, 0, ;
                   nor( SWP_FRAMECHANGED, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER ) )

   RETURN NIL

/*******************************************************************/
//Elimina el menú de una ventana específica
METHOD Eliminar_Menu( hwnd )
   LOCAL hmenu
   LOCAL nmenu
   LOCAL i

   // Recuper el hwnd del menu del programa
   hmenu := ::GetMenu( hwnd )
   IF hmenu <> 0
      // cantidad de menúes
      nmenu := ::GetMenuItemCount( hmenu )
      IF nmenu > 0
         // Recorre todos los menú y los elimina
         FOR i := 1 To nmenu
            ::DeleteMenu( hmenu, 0, nor(MF_BYPOSITION, MF_REMOVE) )
         NEXT

         // Repinta la barra de menú
         ::DrawMenuBar( hwnd )
      ENDIF
   ENDIF

   RETURN NIL

/*******************************************************************/
// Cierra
METHOD Cerrar_Programa( hwnd )
   DEFAULT hwnd := ::hwndcalc

   // Cierra el programa abierto, en este caso la calculadora
   SendMessage( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 )

   RETURN .t.

/*******************************************************************/
// mete la ventana en el contenedor
METHOD incrustar_calculadora( ocontainer )
   LOCAL aRect := {}
   LOCAL nLoop := 0

   ::ocontainer := ocontainer

   // Handle de la aplicación
   ::hwndcalc := FindWindow( 0, ::cTitlecalculator )
   IF ::hwndcalc > 0
      ::Cerrar_Programa( ::hwndcalc )
      ::hwndcalc := NIL
   ENDIF

   // Abre el programa
   MSGRUN( "Ejecutando calculadora...",, ;
           {|| ShellExecute( ,,"calc.exe",,, )} )

   WHILE nLoop <= ::nTime
      // Handle de la aplicación
      ::hwndcalc := FindWindow( 0, ::cTitlecalculator )
      IF ::hwndcalc <> 0
         EXIT
      ENDIF
      SYSREFRESH()
      nLoop += 1
   ENDDO

   // Ocultando la calculadora
   ShowWindow( ::hwndcalc, 0 )

   // Recupera el ancho y alto del área cliente
   aRect := GetClientRect( ::hwndcalc )

   // Redimensiona el picturebox al ancho y alto del programa
   ::ocontainer:nWidth  := ( aRect[4] - aRect[2] ) + 25
   ::ocontainer:nHeight := ( aRect[3] - aRect[1] ) + 55

   // Elimina la barra de título, los menúes y lo incrusta
   ::Eliminar_Menu( ::hwndcalc )
   ::Barra_Titulo( ::hwndcalc, .t. )
   ::Incrustar( ::hwndcalc )
   ::ocontainer:refresh()

   RETURN NIL

/*******************************************************************/
METHOD Incrustar( hwnd )
   LOCAL nret

   // Lo metemos dentro del ocontainer
   SetParent( hwnd, ::ocontainer:hwnd )

   // Maximizamos la ventana incrustada dentro del contenedor, mediante el _
   // Api showWindow, pasándole la constante SHOWMAXIMIZED_eSW
   nret := ShowWindow( hwnd, SHOWMAXIMIZED_eSW )

   RETURN .t.

/*******************************************************************/
// Libera la ventana pasándole en el segundo
// parámetro el valor 0 y la cierra
METHOD liberar_programa( hwnd )
   // Libera el programa
   SetParent( hwnd, 0 )

   // Lo cierra
   ::Cerrar_Programa( hwnd )

   hwnd := 0

   RETURN NIL

/*******************************************************************/
// Recupera el Hwnd de un menú
METHOD GetMenu( hwnd )
   LOCAL pCallTemplate
   LOCAL nRet

   // create call template on first call
   pCallTemplate := DllPrepareCall(  ;
                    "user32.dll"   , ;      // external DLL
                    DC_CALL_STD    , ;      // calling convention
                    "GetMenu" )             // external function

   nRet := DllExecuteCall( pCallTemplate, hwnd )

   RETURN nRet

/*******************************************************************/
// Elimina el menú de una aplicación
METHOD DeleteMenu( hmenu, nposition, wflags )
   LOCAL pCallTemplate
   LOCAL nRet

   // create call template on first call
   pCallTemplate := DllPrepareCall(  ;
                    "user32.dll"   , ;
                    DC_CALL_STD    , ;
                    "DeleteMenu" )

   nRet := DllExecuteCall( pCallTemplate, hmenu, nposition, wflags )

   RETURN nRet

/*******************************************************************/
// Recupera la cantidad de Item de menúes para saber cuantos hay que eliminar
METHOD GetMenuItemCount( hmenu )
   LOCAL pCallTemplate
   LOCAL nRet

   // create call template on first call
   pCallTemplate := DllPrepareCall(  ;
                    "user32.dll"   , ;
                    DC_CALL_STD    , ;
                    "GetMenuItemCount" )

   nRet := DllExecuteCall( pCallTemplate, hmenu )

   RETURN nRet

/*******************************************************************/
// Redibuja - repinta la barra de menú luego de eliminarlo
METHOD DrawMenuBar( hwnd )
   LOCAL pCallTemplate
   LOCAL nRet

   // create call template on first call
   pCallTemplate := DllPrepareCall(  ;
                    "user32.dll"   , ;
                    DC_CALL_STD    , ;
                    "DrawMenuBar" )

   nRet := DllExecuteCall( pCallTemplate, hwnd )

   RETURN nRet

/*******************************************************************/
// Estas tres funciones es para eliminar la barra de título
// del programa que se va a incrustar
METHOD GetWindowLong( hwnd, nindex )
   LOCAL pCallTemplate
   LOCAL nRet

   // create call template on first call
   pCallTemplate := DllPrepareCall(  ;
                    "user32.dll"   , ;
                    DC_CALL_STD    , ;
                    "GetWindowLongA" )

   nRet := DllExecuteCall( pCallTemplate, hwnd, nindex )

   RETURN nRet

/*******************************************************************/
METHOD SetWindowLong( hwnd, nindex, dwnewlong )
   LOCAL pCallTemplate
   LOCAL nRet

   // create call template on first call
   pCallTemplate := DllPrepareCall(  ;
                    "user32.dll"   , ;
                    DC_CALL_STD    , ;
                    "SetWindowLongA" )

   nRet := DllExecuteCall( pCallTemplate, hwnd, nindex, dwnewlong )

   RETURN nRet

/*******************************************************************/
METHOD SetWindowPos( hwnd, hwndinsertafter, x, y, cx, cy, wflags )
   LOCAL pCallTemplate
   LOCAL nRet

   // create call template on first call
   pCallTemplate := DllPrepareCall(  ;
                    "user32.dll"   , ;
                    DC_CALL_STD    , ;
                    "SetWindowPos" )

   nRet := DllExecuteCall( pCallTemplate, hwnd, hwndinsertafter, x, y, cx, cy, wflags )

   RETURN nRet

/*******************************************************************/
 


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: EJECUTAR UN .EXE

Postby Claudio Leiva » Fri Mar 24, 2017 10:52 pm

MUCHAS GRACIAS
LO PROBARE
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm

Re: EJECUTAR UN .EXE

Postby Claudio Leiva » Mon Mar 27, 2017 8:07 pm

ESTIMADO FORO.
PROBÉ EL EJEMPLO PROPORCIONADO Y FUNCIONA OK.. CON CALC.EXE,, PERO AL EJECUTARLO CON OTRO EXE. NO FUNCIONA,, SOLO LO ABRE EN UN VENTA EXTERNA Y NO LO ASOCIA A MI APLICACION

ALGUNA IDEA DE PORQUE.
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm

Re: EJECUTAR UN .EXE

Postby karinha » Mon Mar 27, 2017 8:31 pm

Muestra con estas haciendo.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: EJECUTAR UN .EXE

Postby Claudio Leiva » Mon Mar 27, 2017 9:10 pm

ASI

/*
- autor: wmormar, INCOS - wmormar@hotmail.com
- fecha: 31 . octubre . 2008
- hora: 03.11
*/

#include "fivewin.ch"

FUNCTION main()
LOCAL oBmp
LOCAL tCalc32
LOCAL oCalculator
Local lIncrustar:=.f.
//LOCAL this := Self
LOCAL lSalir := .f.

/*
IF ::oCalculator:classname() == "TDIALOG"
::oCalculator:restore()
::oCalculator:setfocus()
RETURN NIL
ENDIF
DEFINE DIALOG oCalculator RESOURCE "CALCULADORA" TITLE ".:: Calculadora ::." COLOR CLR_BLUE,CLR_WHITE

*/

tCalc32 := TCalculator()
DEFINE WINDOW oCalculator MDI TITLE ".:: Calculadora ::." COLOR CLR_BLUE,CLR_WHITE
DEFINE BITMAP oBmp FILE "calc.bmp" OF oCalculator //TRANSPARENT
oCalculator:bLDblClick := {|| tCalc32:cerrar_programa()}
oCalculator:bRClicked := {|| iif( !lIncrustar,;
(tCalc32:incrustar_calculadora( oCalculator ),lIncrustar:=.t.);
,)}
//oCalculator:bRClicked := {|| tCalc32:normal()}

ACTIVATE WINDOW oCalculator

/*
ON INIT equis(this:oCalculator:hWnd) ;
VALID lSalir */

RETURN NIL

///////////////////////////////////////////////////////////////////////////////

/*
Tomado: Recursos visualbasic
Fecha: 31 . octubre . 2008
Hora: 02.48

INCOS, wmormar
*/

#include "fivewin.ch"
#include "CStruct.ch"
#include "wintypes.ch"

// Constante para la llamada dinámica del API
#define DC_CALL_STD 0x0020

#define SHOWMAXIMIZED_eSW 3
// Constante para usar con el Api DeleteMenu
#define MF_BYPOSITION 0x400
#define MF_REMOVE 0x1000

// Constante para usar con el Api SendMessage para cerrar
// la aplicación ( en este caso La calculadora )
#define SC_CLOSE 61536
#define WM_SYSCOMMAND 274

// Constante para usar con GetWindowLong y SetWindowLong
#define GWL_STYLE -16

// Constantes para SetWindowPos
#define SWP_FRAMECHANGED 0x0020
#define SWP_NOMOVE 0x0002
#define SWP_NOSIZE 0x0001
#define SWP_NOZORDER 0x0004
#define HWND_TOP 0

CLASS TCalculator
// Mantiene el Handle del programa
DATA hwnd
DATA hwndcalc
DATA cTitlecalculator AS CHARACTER INIT "Calculadora"
DATA ocontainer AS OBJECT
DATA nTime AS NUMERIC INIT 25000

METHOD normal()
METHOD barra_titulo( lErase )
METHOD Eliminar_Menu( hwnd )
METHOD Cerrar_Programa( hwnd )
METHOD Cerrar_Programa( hwnd )
METHOD incrustar_calculadora( ocontainer )
METHOD Incrustar( hwnd )
METHOD liberar_programa( hwnd )
METHOD GetMenu( hwnd )
METHOD DeleteMenu( hmenu, nposition, wflags )
METHOD GetMenuItemCount( hmenu )
METHOD DrawMenuBar( hwnd )
METHOD GetWindowLong( hwnd, nindex )
METHOD SetWindowLong( hwnd, nindex, dwnewlong )
METHOD SetWindowPos( hwnd, hwndinsertafter, x, y, cx, cy, wflags )

ENDCLASS

/*******************************************************************/
// Cargando calculadora normal de windows
METHOD normal()
ShellExecute( ::hwnd,,"calc.exe",,, )

RETURN NIL

/*******************************************************************/
// Elimina y reestablece la barra de título de una ventana
METHOD barra_titulo( hwnd, lErase )
LOCAL nStyle

// Almacena en la variable el estilo actual
nStyle := ::GetWindowLong( hwnd, GWL_STYLE )

IF lErase
nStyle := nor( nStyle, WS_CAPTION )
ELSE
nStyle += nor( WS_CAPTION )
ENDIF

// Aplica el nuevo estilo
::SetWindowLong( hwnd, GWL_STYLE, nStyle )

// Mueve de posición la calculadora
::SetWindowPos( ::hwndcalc, HWND_TOP, 0, 0, 0, 0, ;
nor( SWP_FRAMECHANGED, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER ) )

RETURN NIL

/*******************************************************************/
//Elimina el menú de una ventana específica
METHOD Eliminar_Menu( hwnd )
LOCAL hmenu
LOCAL nmenu
LOCAL i

// Recuper el hwnd del menu del programa
hmenu := ::GetMenu( hwnd )
IF hmenu <> 0
// cantidad de menúes
nmenu := ::GetMenuItemCount( hmenu )
IF nmenu > 0
// Recorre todos los menú y los elimina
FOR i := 1 To nmenu
::DeleteMenu( hmenu, 0, nor(MF_BYPOSITION, MF_REMOVE) )
NEXT

// Repinta la barra de menú
::DrawMenuBar( hwnd )
ENDIF
ENDIF

RETURN NIL

/*******************************************************************/
// Cierra
METHOD Cerrar_Programa( hwnd )
DEFAULT hwnd := ::hwndcalc

// Cierra el programa abierto, en este caso la calculadora
SendMessage( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 )

RETURN .t.

/*******************************************************************/
// mete la ventana en el contenedor
METHOD incrustar_calculadora( ocontainer )
LOCAL aRect := {}
LOCAL nLoop := 0

::ocontainer := ocontainer
::hwndcalc := NIL

// Handle de la aplicación
::hwndcalc := FindWindow( 0, ::cTitlecalculator )
IF ::hwndcalc > 0
::Cerrar_Programa( ::hwndcalc )
::hwndcalc := NIL
ENDIF

// Abre el programa
MSGRUN( "Ejecutando calculadora...",, ;
{|| ShellExecute( ,,"C:\DusaSoft\Sueldos\sueldos.exe",,, )} ) "" aca en vez de calc.exe uso este .exe"

WHILE nLoop <= ::nTime
// Handle de la aplicación

::hwndcalc := FindWindow( 0, ::cTitlecalculator )
IF ::hwndcalc <> 0
EXIT
ENDIF
SYSREFRESH()
nLoop += 1
ENDDO

// Ocultando la calculadora
ShowWindow( ::hwndcalc, 0 )


// Recupera el ancho y alto del área cliente
//aRect := GetClientRect( ::hwndcalc )

// Redimensiona el picturebox al ancho y alto del programa
//::ocontainer:nWidth := ( aRect[4] - aRect[2] ) + 25
//::ocontainer:nHeight := ( aRect[3] - aRect[1] ) + 55

// Elimina la barra de título, los menúes y lo incrusta
::Eliminar_Menu( ::hwndcalc )
::Barra_Titulo( ::hwndcalc, .t. )
::Incrustar( ::hwndcalc )
::ocontainer:refresh()

RETURN NIL

/*******************************************************************/
METHOD Incrustar( hwnd )
LOCAL nret

// Lo metemos dentro del ocontainer
SetParent( hwnd, ::ocontainer:hwnd )

// Maximizamos la ventana incrustada dentro del contenedor, mediante el _
// Api showWindow, pasándole la constante SHOWMAXIMIZED_eSW
nret := ShowWindow( hwnd, SHOWMAXIMIZED_eSW )

RETURN .t.

/*******************************************************************/
// Libera la ventana pasándole en el segundo
// parámetro el valor 0 y la cierra
METHOD liberar_programa( hwnd )
// Libera el programa
SetParent( hwnd, 0 )

// Lo cierra
::Cerrar_Programa( hwnd )

hwnd := 0

RETURN NIL

/*******************************************************************/
// Recupera el Hwnd de un menú
METHOD GetMenu( hwnd )
LOCAL pCallTemplate
LOCAL nRet

// create call template on first call
pCallTemplate := DllPrepareCall( ;
"user32.dll" , ; // external DLL
DC_CALL_STD , ; // calling convention
"GetMenu" ) // external function

nRet := DllExecuteCall( pCallTemplate, hwnd )

RETURN nRet

/*******************************************************************/
// Elimina el menú de una aplicación
METHOD DeleteMenu( hmenu, nposition, wflags )
LOCAL pCallTemplate
LOCAL nRet

// create call template on first call
pCallTemplate := DllPrepareCall( ;
"user32.dll" , ;
DC_CALL_STD , ;
"DeleteMenu" )

nRet := DllExecuteCall( pCallTemplate, hmenu, nposition, wflags )

RETURN nRet

/*******************************************************************/
// Recupera la cantidad de Item de menúes para saber cuantos hay que eliminar
METHOD GetMenuItemCount( hmenu )
LOCAL pCallTemplate
LOCAL nRet

// create call template on first call
pCallTemplate := DllPrepareCall( ;
"user32.dll" , ;
DC_CALL_STD , ;
"GetMenuItemCount" )

nRet := DllExecuteCall( pCallTemplate, hmenu )

RETURN nRet

/*******************************************************************/
// Redibuja - repinta la barra de menú luego de eliminarlo
METHOD DrawMenuBar( hwnd )
LOCAL pCallTemplate
LOCAL nRet

// create call template on first call
pCallTemplate := DllPrepareCall( ;
"user32.dll" , ;
DC_CALL_STD , ;
"DrawMenuBar" )

nRet := DllExecuteCall( pCallTemplate, hwnd )

RETURN nRet

/*******************************************************************/
// Estas tres funciones es para eliminar la barra de título
// del programa que se va a incrustar
METHOD GetWindowLong( hwnd, nindex )
LOCAL pCallTemplate
LOCAL nRet

// create call template on first call
pCallTemplate := DllPrepareCall( ;
"user32.dll" , ;
DC_CALL_STD , ;
"GetWindowLongA" )

nRet := DllExecuteCall( pCallTemplate, hwnd, nindex )

RETURN nRet

/*******************************************************************/
METHOD SetWindowLong( hwnd, nindex, dwnewlong )
LOCAL pCallTemplate
LOCAL nRet

// create call template on first call
pCallTemplate := DllPrepareCall( ;
"user32.dll" , ;
DC_CALL_STD , ;
"SetWindowLongA" )

nRet := DllExecuteCall( pCallTemplate, hwnd, nindex, dwnewlong )

RETURN nRet

/*******************************************************************/
METHOD SetWindowPos( hwnd, hwndinsertafter, x, y, cx, cy, wflags )
LOCAL pCallTemplate
LOCAL nRet

// create call template on first call
pCallTemplate := DllPrepareCall( ;
"user32.dll" , ;
DC_CALL_STD , ;
"SetWindowPos" )

nRet := DllExecuteCall( pCallTemplate, hwnd, hwndinsertafter, x, y, cx, cy, wflags )

RETURN nRet

/*******************************************************************/
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm


Re: EJECUTAR UN .EXE

Postby Claudio Leiva » Wed Mar 29, 2017 11:12 pm

ESTIMADO,, SIGO CON EL LIO

IMAGINEN LO SIGUIENTE,,

EXISTE UNA VENTANA PADRE,, Y QUE DENTRO DE ELLA SE PUEDA ABRIR CUALQUIER .EXE, PERO ESO LO DECIDE EL CLIENTE, COMO POR EJEMPLO ABRIR UN NOTEPAD++ O UNA APLICACION DE REMUNERACIONES..

EL LIO QUE TENGO ES COMO CAPTURO EL HANDLE DE ESE .EXE, QUE NO SE CUAL ELIGIRÁ EL USUARIO
SE QUE CON:

FindWindow( 0, "ACA EL TITULO DE LA APLICACION" ) lo puedo encontrar.
hay una forma de obtenerlo sin tener el titulo
no doy tiros

saludos
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm

Re: EJECUTAR UN .EXE

Postby Claudio Leiva » Thu Mar 30, 2017 4:47 pm

alguna idea?
Claudio Leiva
 
Posts: 12
Joined: Fri Mar 17, 2017 8:46 pm

Re: EJECUTAR UN .EXE

Postby Antonio Linares » Thu Mar 30, 2017 9:56 pm

Claudio,

He intentado asi, pero parece que no funciona.

Intento localizar el handle de la aplicación que se ha ejecutado

exein.prg
Code: Select all  Expand view
#include "FiveWin.ch"

#define GWL_HINSTANCE -6

function Main()

   local oWnd, oBar

   DEFINE WINDOW oWnd

   DEFINE BUTTONBAR oBar OF oWnd 2015 SIZE 40, 40

   DEFINE BUTTON OF oBar ACTION OpenExe()

   ACTIVATE WINDOW oWnd

return nil

function OpenExe()

   local cEXE := "c:\windows\notepad"
   local hInst := GetModuleHandle( cEXE )

   ShellExecute( 0, "open", cEXE,,, 1 )

   EnumChildWindows( GetDesktopWindow(),;
                     { | hWnd | If( hInst == GetWindowLong( hWnd, GWL_HINSTANCE ), MsgInfo( "si" ),) } )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: EJECUTAR UN .EXE

Postby Antonio Linares » Thu Mar 30, 2017 9:57 pm

En teoria ShellExecute() debería retornar el valor de dicho handle, pero parece que no es así
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 81 guests