running a program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adolfo

    #1

    running a program

    hi,

    the code doesn't start the game i want it to, dont know why. If change
    the path & file name to "notepad.ex e for example, the code works great.

    Does anyone know why the game would start?

    If someone can please help me out here, i'd appreciate it.

    thanks


    --------------------------------
    Option Explicit

    ' ShellWat sample by Matt Hart - mhart@taascforc e.com
    ' http://www.webczar.com/defcon/mh/vbhelp.html
    ' http://www.webczar.com/defcon/mh
    '
    ' Shows how to shell to another program, and wait until it finishes
    ' before continuing.

    Private Declare Function WaitForSingleOb ject Lib "kernel32" _
    (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

    Private Declare Function CloseHandle Lib "kernel32" _
    (ByVal hObject As Long) As Long

    Private Declare Function OpenProcess Lib "kernel32" _
    (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
    ByVal dwProcessId As Long) As Long


    Private Const INFINITE = -1&
    Private Const SYNCHRONIZE = &H100000

    Private Sub Command1_Click( )
    Dim iTask As Long, ret As Long, pHandle As Long, i As String
    i = "C:\Program Files\EA SPORTS\Champcar \openwheel.exe"
    iTask = Shell(i, vbNormalFocus)
    pHandle = OpenProcess(SYN CHRONIZE, False, iTask)
    ret = WaitForSingleOb ject(pHandle, INFINITE)
    ret = CloseHandle(pHa ndle)
    'MsgBox "Process Finished!"
    End
    End Sub
    --------------------------------
Working...