Check whether the EXE is running or not ???

[b][red]This message was edited by aarunlal at 2005-7-22 20:50:8[/red][/b][hr]
Is it possible to find whether a particular EXE file is running or not ?how can we identify using VB ? If so how how it is ?

hope u respond sooon

regards
Arunlal


Comments

  • : [b][red]This message was edited by aarunlal at 2005-7-22 20:50:8[/red][/b][hr]
    : Is it possible to find whether a particular EXE file is running or not ?how can we identify using VB ? If so how how it is ?
    :
    : hope u respond sooon
    :
    : regards
    : Arunlal
    :
    :
    :

    It is code in C++ working under mingw and vc6 runtimes.
    All You should to compile it in C++ dll project exporting this function and import it in VB (i guest You know how You should do it).
    This may be not working on older Windows (95) but I don't remember.

    Other approach is to import in VB functions: CreateToolhelp32Snapshot, Process32First etc. but I don't remember what doing with structures definictions.

    Now I'am working with Java (with C++ before), with VB 5/6 I end 5 year ago.

    #include
    #include

    /**
    * @return TRUE - success
    */
    bool isExeRunning(const char *zExeName, bool *pbRunning) {

    if (! pbRunning) return FALSE;
    PROCESSENTRY32 pe;
    BOOL bSuccess = TRUE;
    *pbRunning = FALSE;
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    if (hSnapshot!=INVALID_HANDLE_VALUE) {
    BOOL bRes = Process32First(hSnapshot, &pe);
    while (bRes==TRUE) {
    if (0==lstrcmpi(zExeName, pe.szExeFile)) {
    *pbRunning = TRUE;
    break;
    }
    bRes = Process32Next(hSnapshot, &pe);
    }
    if (bRes!=TRUE && GetLastError()!=ERROR_NO_MORE_FILES) {
    bSuccess = FALSE;
    }
    CloseHandle(hSnapshot);
    } else {
    bSuccess = FALSE;
    }
    return bSuccess;

    }

  • hi i don't have no idea abt VCC++ can u help me with VB6/VB5 ???
    hope u respond soon


    : : [b][red]This message was edited by aarunlal at 2005-7-22 20:50:8[/red][/b][hr]
    : : Is it possible to find whether a particular EXE file is running or not ?how can we identify using VB ? If so how how it is ?
    : :
    : : hope u respond sooon
    : :
    : : regards
    : : Arunlal
    : :
    : :
    : :
    :
    : It is code in C++ working under mingw and vc6 runtimes.
    : All You should to compile it in C++ dll project exporting this function and import it in VB (i guest You know how You should do it).
    : This may be not working on older Windows (95) but I don't remember.
    :
    : Other approach is to import in VB functions: CreateToolhelp32Snapshot, Process32First etc. but I don't remember what doing with structures definictions.
    :
    : Now I'am working with Java (with C++ before), with VB 5/6 I end 5 year ago.
    :
    : #include
    : #include
    :
    : /**
    : * @return TRUE - success
    : */
    : bool isExeRunning(const char *zExeName, bool *pbRunning) {
    :
    : if (! pbRunning) return FALSE;
    : PROCESSENTRY32 pe;
    : BOOL bSuccess = TRUE;
    : *pbRunning = FALSE;
    : HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    : if (hSnapshot!=INVALID_HANDLE_VALUE) {
    : BOOL bRes = Process32First(hSnapshot, &pe);
    : while (bRes==TRUE) {
    : if (0==lstrcmpi(zExeName, pe.szExeFile)) {
    : *pbRunning = TRUE;
    : break;
    : }
    : bRes = Process32Next(hSnapshot, &pe);
    : }
    : if (bRes!=TRUE && GetLastError()!=ERROR_NO_MORE_FILES) {
    : bSuccess = FALSE;
    : }
    : CloseHandle(hSnapshot);
    : } else {
    : bSuccess = FALSE;
    : }
    : return bSuccess;
    :
    : }
    :
    :

  • : hi i don't have no idea abt VCC++ can u help me with VB6/VB5 ???
    : hope u respond soon
    :
    :
    : : : [b][red]This message was edited by aarunlal at 2005-7-22 20:50:8[/red][/b][hr]
    : : : Is it possible to find whether a particular EXE file is running or not ?how can we identify using VB ? If so how how it is ?
    : : :
    : : : hope u respond sooon
    : : :
    : : : regards
    : : : Arunlal
    : : :
    : : :
    : : :
    : :
    : : It is code in C++ working under mingw and vc6 runtimes.
    : : All You should to compile it in C++ dll project exporting this function and import it in VB (i guest You know how You should do it).
    : : This may be not working on older Windows (95) but I don't remember.
    : :
    : : Other approach is to import in VB functions: CreateToolhelp32Snapshot, Process32First etc. but I don't remember what doing with structures definictions.
    : :
    : : Now I'am working with Java (with C++ before), with VB 5/6 I end 5 year ago.
    : :
    : : #include
    : : #include
    : :
    : : /**
    : : * @return TRUE - success
    : : */
    : : bool isExeRunning(const char *zExeName, bool *pbRunning) {
    : :
    : : if (! pbRunning) return FALSE;
    : : PROCESSENTRY32 pe;
    : : BOOL bSuccess = TRUE;
    : : *pbRunning = FALSE;
    : : HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    : : if (hSnapshot!=INVALID_HANDLE_VALUE) {
    : : BOOL bRes = Process32First(hSnapshot, &pe);
    : : while (bRes==TRUE) {
    : : if (0==lstrcmpi(zExeName, pe.szExeFile)) {
    : : *pbRunning = TRUE;
    : : break;
    : : }
    : : bRes = Process32Next(hSnapshot, &pe);
    : : }
    : : if (bRes!=TRUE && GetLastError()!=ERROR_NO_MORE_FILES) {
    : : bSuccess = FALSE;
    : : }
    : : CloseHandle(hSnapshot);
    : : } else {
    : : bSuccess = FALSE;
    : : }
    : : return bSuccess;
    : :
    : : }
    : :
    : :
    :
    :

    Hi,
    this is borizm's code in VB.
    [code]Option Explicit

    Private Const TH32CS_SNAPPROCERSS = &H2&

    Private Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szExeFile As String * 260
    End Type

    Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
    Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
    Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long

    Private Sub Form_Load()
    If IsExeRunning("calc.exe") Then
    MsgBox "Calc is running"
    Else
    MsgBox "Calc is NOT running"
    End If
    End Sub

    Private Function IsExeRunning(ByVal ExeName As String) As Boolean
    Dim hSnap As Long, pe As PROCESSENTRY32, ret As Long
    hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCERSS, 0)
    If hSnap <> 0 Then
    pe.dwSize = Len(pe)
    ret = Process32First(hSnap, pe)
    Do While ret <> 0
    If Mid(pe.szExeFile, 1, InStr(1, pe.szExeFile, Chr(0)) - 1) = ExeName Then
    IsExeRunning = True
    Exit Do
    End If
    ret = Process32Next(hSnap, pe)
    Loop
    Else
    IsExeRunning = False
    End If
    End Function[/code]But it has one disadvantage: It do not make any different between c:calc.exe and c:windowssystem32calc.exe.
    There should be one more test to get process exe path from process ID, but if your app has quite unique exename, or you don't care (i suppose you really do not) what's the path of your exe, it's quite good.

    Another way (if you know whole path) is to copy exefile, try to delete and if error occurs - exe is running. Do not forget to renew original exe from your copy :) But I thing if you'll need this on Windows 2003 server, you'll have to try to read the exe after deleting it to make sure it's deleted.

    Hope this helps

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


  • dear Pavlin thank you very much for your immediate and useful respose ..
    what is your personal emailID ?
    have intrest to contact u ? iam also working in .Net Technologies ...

    reagrds
    Arunlal


    : : hi i don't have no idea abt VCC++ can u help me with VB6/VB5 ???
    : : hope u respond soon
    : :
    : :
    : : : : [b][red]This message was edited by aarunlal at 2005-7-22 20:50:8[/red][/b][hr]
    : : : : Is it possible to find whether a particular EXE file is running or not ?how can we identify using VB ? If so how how it is ?
    : : : :
    : : : : hope u respond sooon
    : : : :
    : : : : regards
    : : : : Arunlal
    : : : :
    : : : :
    : : : :
    : : :
    : : : It is code in C++ working under mingw and vc6 runtimes.
    : : : All You should to compile it in C++ dll project exporting this function and import it in VB (i guest You know how You should do it).
    : : : This may be not working on older Windows (95) but I don't remember.
    : : :
    : : : Other approach is to import in VB functions: CreateToolhelp32Snapshot, Process32First etc. but I don't remember what doing with structures definictions.
    : : :
    : : : Now I'am working with Java (with C++ before), with VB 5/6 I end 5 year ago.
    : : :
    : : : #include
    : : : #include
    : : :
    : : : /**
    : : : * @return TRUE - success
    : : : */
    : : : bool isExeRunning(const char *zExeName, bool *pbRunning) {
    : : :
    : : : if (! pbRunning) return FALSE;
    : : : PROCESSENTRY32 pe;
    : : : BOOL bSuccess = TRUE;
    : : : *pbRunning = FALSE;
    : : : HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    : : : if (hSnapshot!=INVALID_HANDLE_VALUE) {
    : : : BOOL bRes = Process32First(hSnapshot, &pe);
    : : : while (bRes==TRUE) {
    : : : if (0==lstrcmpi(zExeName, pe.szExeFile)) {
    : : : *pbRunning = TRUE;
    : : : break;
    : : : }
    : : : bRes = Process32Next(hSnapshot, &pe);
    : : : }
    : : : if (bRes!=TRUE && GetLastError()!=ERROR_NO_MORE_FILES) {
    : : : bSuccess = FALSE;
    : : : }
    : : : CloseHandle(hSnapshot);
    : : : } else {
    : : : bSuccess = FALSE;
    : : : }
    : : : return bSuccess;
    : : :
    : : : }
    : : :
    : : :
    : :
    : :
    :
    : Hi,
    : this is borizm's code in VB.
    : [code]Option Explicit
    :
    : Private Const TH32CS_SNAPPROCERSS = &H2&
    :
    : Private Type PROCESSENTRY32
    : dwSize As Long
    : cntUsage As Long
    : th32ProcessID As Long
    : th32DefaultHeapID As Long
    : th32ModuleID As Long
    : cntThreads As Long
    : th32ParentProcessID As Long
    : pcPriClassBase As Long
    : dwFlags As Long
    : szExeFile As String * 260
    : End Type
    :
    : Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
    : Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
    : Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
    :
    : Private Sub Form_Load()
    : If IsExeRunning("calc.exe") Then
    : MsgBox "Calc is running"
    : Else
    : MsgBox "Calc is NOT running"
    : End If
    : End Sub
    :
    : Private Function IsExeRunning(ByVal ExeName As String) As Boolean
    : Dim hSnap As Long, pe As PROCESSENTRY32, ret As Long
    : hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCERSS, 0)
    : If hSnap <> 0 Then
    : pe.dwSize = Len(pe)
    : ret = Process32First(hSnap, pe)
    : Do While ret <> 0
    : If Mid(pe.szExeFile, 1, InStr(1, pe.szExeFile, Chr(0)) - 1) = ExeName Then
    : IsExeRunning = True
    : Exit Do
    : End If
    : ret = Process32Next(hSnap, pe)
    : Loop
    : Else
    : IsExeRunning = False
    : End If
    : End Function[/code]But it has one disadvantage: It do not make any different between c:calc.exe and c:windowssystem32calc.exe.
    : There should be one more test to get process exe path from process ID, but if your app has quite unique exename, or you don't care (i suppose you really do not) what's the path of your exe, it's quite good.
    :
    : Another way (if you know whole path) is to copy exefile, try to delete and if error occurs - exe is running. Do not forget to renew original exe from your copy :) But I thing if you'll need this on Windows 2003 server, you'll have to try to read the exe after deleting it to make sure it's deleted.
    :
    : Hope this helps
    :
    : [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
    :
    : [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
    :
    :
    :

  • [b][red]This message was edited by sajeesh at 2006-6-26 1:32:14[/red][/b][hr]
    Hi,

    i want to know how to create exe in visual basic program.
    am using vb 6 and back end as ms acces
    pls help me..
    i tried..using the file menu..make exe option..but when i copied the exe to another system..its not working..means database is not working properly...

    pls reply soon..i need it very urgently...
    pls give me the complete details on regarding the EXE creation.

    regards,
    sajeesh


  • : [b][red]This message was edited by sajeesh at 2006-6-26 1:32:14[/red][/b][hr]
    : Hi,
    :
    : i want to know how to create exe in visual basic program.
    : am using vb 6 and back end as ms acces
    : pls help me..
    : i tried..using the file menu..make exe option..but when i copied the exe to another system..its not working..means database is not working properly...
    :
    : pls reply soon..i need it very urgently...
    : pls give me the complete details on regarding the EXE creation.
    :
    : regards,
    : sajeesh
    :
    :
    :
    Hi,
    there may be several reasons why your app is not running correctly..
    Most common is request for msvbvm60.dll and other needed libraries. I guess this is not your case (system will throw error and tell you the name of missing library - just copy it to the new system (system32 directory, or directory of your application).

    When you're using MS Access with your application, there's even larger pool of possible problems.. Make sure:
    Target machine has MS Office (MS Access, at least!) installed - the same or newer version than is yours.
    Target machine has latest updates (Latest MDAC update!)
    And now starts deeper problems..
    There may be mistake (or damage) in computer ODBC drivers, some child mistake in paths (file.mdb is in different location or you suppose it to be in "current" directory, but "current" directory may be different etc..), or there's some security issue in MS Access of target machine etc..

    P.S.: Next time, create new thread for new message, please!

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories