locked
Start application on device switch on or soft reset RRS feed

  • Question

  • Hi,

    I have an application that needs started either when Windows Mobile first boots after being switched on or else after a soft reset.  I was trying to do this using CeRunAppAtEvent pinvoke method.  But I can only get this going for device changed or wakeup.  Which isn't working when I need it to.  Is there a better way?

    The pinvoke code I was using is:

            [DllImport("CoreDLL.dll")]
            private extern static int CeRunAppAtEvent(string application, NotificationEvent eventId);

            private enum NotificationEvent
            {
                None = 0,
                DeviceChange = 7,
                Wakeup = 11
            }


    Then call this line of code:

           CeRunAppAtEvent(ApplicationPath, NotificationEvent.Wakeup);

    I also noticed that sometimes when I added the event, when I use task manager to go and look at the events after I've restarted the device - on occasion it has disappeared from the notification queue.

    Any advice is appreciated.


    Rob McCabe
    Thursday, December 17, 2009 11:43 AM

Answers

  • Why not just create a shortcut to your application in \Windows\Startup?  You can do this with either SHCreateShortcut  or you can do it manually.

    The format of shortcuts on Windows Mobile devices is simple. It will always be in the form 00#"<\program Files\path>", where 00 is replaced with the number of characters that appear after the ‘#’ sign; the ‘#’ is a delimiter, and then the complete path to the executable. The following is an example of a shortcut to Windows Media Player:

    23#“\windows\wmplayer.exe”
    The Wakeup event that you are using is not for the device booting up.  it is for the device coming out of the suspended state.
    It takes all the running you can do to stay in one place.If you want to get somewhere else,you must try to run at least twice as fast as that.
    • Proposed as answer by Joel Ivory Johnson Thursday, December 17, 2009 1:16 PM
    • Marked as answer by Rob McCabe Thursday, December 17, 2009 2:56 PM
    Thursday, December 17, 2009 1:16 PM

All replies

  • Why not just create a shortcut to your application in \Windows\Startup?  You can do this with either SHCreateShortcut  or you can do it manually.

    The format of shortcuts on Windows Mobile devices is simple. It will always be in the form 00#"<\program Files\path>", where 00 is replaced with the number of characters that appear after the ‘#’ sign; the ‘#’ is a delimiter, and then the complete path to the executable. The following is an example of a shortcut to Windows Media Player:

    23#“\windows\wmplayer.exe”
    The Wakeup event that you are using is not for the device booting up.  it is for the device coming out of the suspended state.
    It takes all the running you can do to stay in one place.If you want to get somewhere else,you must try to run at least twice as fast as that.
    • Proposed as answer by Joel Ivory Johnson Thursday, December 17, 2009 1:16 PM
    • Marked as answer by Rob McCabe Thursday, December 17, 2009 2:56 PM
    Thursday, December 17, 2009 1:16 PM
  • Thanks for the advice Joel. I think creating the shortcut might be a better option then. One thing - I dont want to do this as part of the cab file install as its an option that can be switched on and off. So I need to be able to do this programatically. Is there any way to create shortcuts using code? Thanks.
    Rob McCabe
    Thursday, December 17, 2009 1:27 PM
  • Yes, I describe the method for doing it in code above.
    It takes all the running you can do to stay in one place.If you want to get somewhere else,you must try to run at least twice as fast as that.
    Thursday, December 17, 2009 2:42 PM
  • Thanks, that pointed me in the right direction.  I found this link useful also:


    Rob McCabe
    Thursday, December 17, 2009 2:56 PM