Kako da i VB aplikacije pokrenem neki drugi exe?
Prikazujem rezultate 1 do 5 od 5

Tema: Kako da i VB aplikacije pokrenem neki drugi exe?

  1. #1
    Početnik
    Učlanjen
    03.05.2005.
    Pol
    ženski
    Poruke
    19
    Reputaciona moć
    0

    Podrazumevano Kako da i VB aplikacije pokrenem neki drugi exe?

    Kako da iz Visual Basic-ove aplikacije pokrenem neki drugi exe fajl?



  2. #2
    Iskusan codemaker (avatar)
    Učlanjen
    05.04.2004.
    Lokacija
    Beograd
    Poruke
    6.416
    Reputaciona moć
    0

    Podrazumevano Re: Kako da i VB aplikacije pokrenem neki drugi exe?

    Pa u temi ispod ove, pricali smo o tome... Cemu sad poseban topic?

  3. #3
    Početnik
    Učlanjen
    03.05.2005.
    Pol
    ženski
    Poruke
    19
    Reputaciona moć
    0

    Podrazumevano Re: Kako da i VB aplikacije pokrenem neki drugi exe?

    Pa niko mi nije odgovorio.Ono u odgovorima mi nije pomoglo, jer ne funkcionise u VB, pa mozda neko zna nesto vise o tome.

  4. #4
    Iskusan codemaker (avatar)
    Učlanjen
    05.04.2004.
    Lokacija
    Beograd
    Poruke
    6.416
    Reputaciona moć
    0

    Podrazumevano Re: Kako da i VB aplikacije pokrenem neki drugi exe?

    Uvek se pitam, zasto ne citate Help-ove, zasto ne konsultujete Internet, zasto ne procitate neku knjigu o programskom jeziku koji koristitte? Ne mogu da verujem da pokusavas da programiras u VB a da nemas ni knjigu, a tamo sigurno to pise, samo je treba prelistati....
    Evo, nakon 49 sekundi trazenja po netu:

    ********** SA INTERNETA
    Programming:Visual Basic Classic/External Processes
    From Wikibooks, the open-content textbooks collection
    < Programming:Visual Basic Classic
    Jump to: navigation, search
    [edit]

    Introduction

    It is often the case that a program already exists to do some job so rather than rewrite the program in Visual Basic it is more efficient to run the existing program from Visual Basic. This can work very well for command line programs or scripts written in any language.

    The general scheme is to create a string containing the command line, call a function to run it and then wait for the command to complete. There are many refinements that can be made including all sorts of ways of sending data to the new process, reading results from it, pausing it, setting its priority and so on.


    [edit]

    The Shell Function

    The simplest way of running an external program is to do something like this:

    Shell "cmd /c dir %temp%"

    Shell is a built in Visual Basic function that executes a command line and returns a handle to that process. Shell takes an optional argument that controls the window style of the new process (maximized, normal, hidden, etc.).

    Unfortunately running another program like this doesn't give you much control over what is happening. In particular, there is no obvious way to find out if the program has completed its work.

    Luckily Shell actually does slightly more than launch the program it also returns the process id. This is the number displayed by Task Managers and can be used to check the status of the process. Unfortunately, as is so often the case with Visual Basic and Windows there is no built in function nor even a single API function that can use it directly so we must write a little more code. First we must declare some API functions and some constants:

    Option Explicit

    Const SYNCHRONIZE = &H100000
    Const INFINITE = &HFFFF 'Wait forever
    Const WAIT_OBJECT_0 = 0 'The state of the specified object is signaled.
    Const WAIT_TIMEOUT = &H102 'The time-out interval elapsed, and the object’s state is nonsignaled.

    Private Declare Function OpenProcess Lib "kernel32" _
    (ByVal dwDesiredAccess As Long, _
    ByVal bInheritHandle As Long, _
    ByVal dwProcessId As Long) _
    As Long
    Private Declare Function WaitForSingleObject Lib "kernel32" _
    (ByVal hHandle As Long, _
    ByVal dwMilliseconds As Long) _
    As Long
    Private Declare Function CloseHandle Lib "kernel32" _
    (ByVal hObject As Long) _
    As Long

    Dim ProcessID As Long
    Dim hProcess As Long


    Here is an example of a function that executes a command and waits for it to complete:

    Function ShellWait(CommandLine As String, _
    TimeOut As Long, _
    WindowState As VbAppWinStyle) As Boolean

    Dim ProcessID As Long
    Dim hProcess As Long

    ProcessID = Shell(CommandLine)
    If ProcessID Then
    'non-zero (True) so Shell worked
    ' Get a process handle for the PID (Wait takes a handle)
    hProcess = OpenProcess(SYNCHRONIZE, False, ProcessID)
    If hProcess Then
    ' Got process handle
    ' Wait until process finishes before going on
    If WaitForSingleObject(hProcess, TimeOut) = WAIT_OBJECT_0 Then
    ShellWait = True
    Else
    ShellWait = False
    End If
    Else
    'Failed to get process handle.
    'Perhaps the process terminated very quickly
    'or it might not really have executed at all even though Windows
    ' started a process.
    ShellWait = False
    End If
    Else
    ' PID zero (False) so Shell failed
    ShellWait = False
    End If
    End Function


    Call it like this:

    If ShellWait("calc.exe") then
    MsgBox "Success :-)"
    Else
    msgBox "Failure :-("
    End If

    ***********
    Nadam se da ces se snaci....

  5. #5
    Početnik
    Učlanjen
    03.05.2005.
    Pol
    ženski
    Poruke
    19
    Reputaciona moć
    0

    Podrazumevano Re: Kako da i VB aplikacije pokrenem neki drugi exe?

    Radi! Hvala!

Slične teme

  1. WoW,GW,neki drugi MMORPG?
    Autor *JV* u forumu Video igre
    Odgovora: 36
    Poslednja poruka: 09.06.2008., 17:12
  2. avi u neki drugi format
    Autor danilo!@# u forumu Softver
    Odgovora: 6
    Poslednja poruka: 26.06.2004., 13:36
  3. Intel P-4 ili neki drugi
    Autor Deki Salzburg u forumu Hardver
    Odgovora: 1
    Poslednja poruka: 23.10.2003., 19:44

Pravila za slanje poruka

  • Ne možete kreirati novu temu
  • Ne možete poslati odgovor
  • Ne možete dodati priloge
  • Ne možete prepraviti svoju poruku
  •