Check if a application was running

Discussion in 'Questions (Windows Mobile)' started by newbie, Apr 18, 2009.

  1. newbie

    newbie Member Licensed User


    is there a possibility to check if a program was running or not ?
    I want to make that the Application can't start two or more times.

    kind regards from germany
  2. specci48

    specci48 Well-Known Member Licensed User

    Hello Gerd,

    as far as I know this can't be done in a simple way. :sign0013:

    The "workaround" is to read all the running/active processes (with GetProcesses from the useful library of dzt) and search for the own filename in the returned table.

  3. Erel

    Erel Administrator Staff Member Licensed User

    On the device, only a single instance of an application can run. Trying to run an already running program just brings the program to the front.
  4. pinoy_ako

    pinoy_ako Member Licensed User

    hi erel,

    but why my program set to run at power up, runs at multiple instance? program is running like, 3 or more times at the same time on power up.
  5. newbie

    newbie Member Licensed User

    Multiple Instance

    Hi Erel,

    that is not correct.

    My App. run on a MDE Device with CE 5.0
    it is no Problem to start and run two or more instances.
    Only the there is not enough memory i get a Error.

  6. Erel

    Erel Administrator Staff Member Licensed User

    The 'single instance' is a feature of Windows Mobile and it doesn't exist in windows ce.
  7. pinoy_ako

    pinoy_ako Member Licensed User

    hi erel,

    does it really have to show error like "not enough memory" if a program is set to run at start up? i have that same error. but if i just run the program manually, no error like that.

  8. Erel

    Erel Administrator Staff Member Licensed User

    No. There is some other problem most probably.

    You appear as an unlicensed user. Please send me your order details and I'll fix it.
  9. pinoy_ako

    pinoy_ako Member Licensed User

    i still dont have a license. im just trying to develope a program for may bluetooth enable hardware.

  10. Erel

    Erel Administrator Staff Member Licensed User

    So how are you running it at startup?
  11. HARRY

    HARRY Active Member Licensed User


    I wonder whether it is (still) true that on the device a program can only be started once.
    I run Windows 6.1 on my device and I can easily start two occurrences of the same program.

    I did this accidentely by tapping twice the program name on the Start menu (impatient!). One occurrenc ran into problems because it tried to delete a file which was in use by the other occurrence.

    I tried to avoid that problem using the following code in AppStart:

    If cPPC=True Then
    For i = 0 To ArrayLen(ProcArr()) -1
    If StrToUpper(ProcArr(i))=StrToUpper("MyProgram.EXE") Then
    Runs =Runs+1
    End If
    Next i
    End If
    If Runs > 1 Then
    Msgbox("MyProgram runs already. This occurrence is closed.",cMsgboxOK,cMsgboxExclamation)
    End If

    Unfortunately this doesnt work. I think that the processes are created so fast and it takes so long to really start the program, that both occurrences find out that the program is already running.

    I use a downloaded, flashed version of Windows Mobiule 6.1 on my device, but I can hardly think that that is the cause of this 'problem'.

    Please comment.

  12. Erel

    Erel Administrator Staff Member Licensed User

    Windows Mobile should allow only one instance of your application to run.
    When you start a running program, it should become focused instead of creating another process. This is not handled by Basic4ppc but rather by the OS.
    I think that the problem only occur when your application starts. You can create a small program that launches your full program (and waits till it closes).
    This launcher program will load quick and hopefully the OS will succeed in forcing only one instance of it.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice