Solved

Windows mobile application restart

Posted on 2010-08-25
8
1,256 Views
Last Modified: 2013-12-21
Hello experts,

Is there any way to restart my windows mobile 6.1 application programmatically? i use vb.net

thanks
0
Comment
Question by:spiral2007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 18

Expert Comment

by:Dennis Aries
ID: 33518981
Try this
Sub Restart(ByVal program As String)
        For Each proc As Process In Process.GetProcesses
            If proc.ProcessName = program Then proc.Kill()
        Next
        Process.Start(program)
   End Sub
0
 
LVL 3

Expert Comment

by:efatihan
ID: 33518988
Take this,

#Region "declares for softreset (KernelIOControl)"

' Control Code flags
Private Const FILE_DEVICE_UNKNOWN As UInteger = &H22
Private Const FILE_DEVICE_HAL As UInteger = &H101
Private Const FILE_DEVICE_CONSOLE As UInteger = &H102
Private Const FILE_DEVICE_PSL As UInteger = &H103
Private Const METHOD_BUFFERED As UInteger = 0
Private Const METHOD_IN_DIRECT As UInteger = 1
Private Const METHOD_OUT_DIRECT As UInteger = 2
Private Const METHOD_NEITHER As UInteger = 3
Private Const FILE_ANY_ACCESS As UInteger = 0
Private Const FILE_READ_ACCESS As UInteger = &H1
Private Const FILE_WRITE_ACCESS As UInteger = &H2

Private Shared Function CTL_CODE(DeviceType As UInteger, [Function] As UInteger, Method As UInteger, Access As UInteger) As UInteger
      Return ((DeviceType << 16) Or (Access << 14) Or ([Function] << 2) Or Method)
End Function

''' <summary>
''' This function provides the kernel with a generic I/O control for
''' carrying out I/O operations.
''' </summary>
''' <param name="dwIoControlCode">I/O control code, which should support the
''' OAL I/O controls. For a list of these I/O controls, see Supported
''' OAL APIs.</param>
''' <param name="lpInBuf">Pointer to the input buffer.</param>
''' <param name="nInBufSize">Size, in bytes, of lpInBuf.</param>
''' <param name="lpOutBuf">Pointer to the output buffer.</param>
''' <param name="nOutBufSize">Maximum number of bytes that can be returned in
''' lpOutBuf.</param>
''' <param name="lpBytesReturned">Address of a DWORD that receives the size,
''' in bytes, of the data returned.</param>
''' <returns>TRUE indicates success; FALSE indicates failure.</returns>
<DllImport("Coredll.dll")> _
Private Shared Function KernelIoControl(dwIoControlCode As UInteger, lpInBuf As IntPtr, nInBufSize As UInteger, lpOutBuf As IntPtr, nOutBufSize As UInteger, ByRef lpBytesReturned As UInteger) As UInteger
End Function
#End Region




''' <summary>
''' the method needed to be called to actually reset the device.
''' </summary>
Public Shared Sub ResetDevice()
      Dim bytesReturned As UInteger = 0
      Dim IOCTL_HAL_REBOOT As UInteger = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
      KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, bytesReturned)
End Sub
0
 
LVL 3

Expert Comment

by:efatihan
ID: 33519013
0
Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

 

Author Comment

by:spiral2007
ID: 33519085
efatihan i want to restart my application not my device.

djjaries your way is for windows form application ? i use windows mobile 6.1 compact framework


any other suggestions?
0
 
LVL 3

Accepted Solution

by:
efatihan earned 500 total points
ID: 33519152
sorry, i misunderstood your question.
in compact framework, to restart your application you have two choices, one is the following
(i am not sure if it is going to work on wm 6.1)

Public Shared Sub RestartApplication()
      Dim fileName As String = Assembly.GetExecutingAssembly().GetName().CodeBase
      Application.[Exit]()
      Dim startInfo As New ProcessStartInfo(fileName)
      Process.Start(startInfo)
End Sub


the other one is to schedule your application using CeRunAppAtTime to wake up after you close it.
the example is at the following url:
http://www.pinvoke.net/default.aspx/coredll.CeRunAppAtTime

just add few seconds to "now" and let the application start itself.

good luck.
0
 

Author Comment

by:spiral2007
ID: 33520080
hello efatihan i follow the http://www.pinvoke.net/default.aspx/coredll.CeRunAppAtTime
example and it works only if i schedule the wakeup after 10 sec.
is there any way to make this wakeup operation start faster or immediately? (if i change the seconds variable and put a value less than 10sec nothing happens)

thanks
0
 
LVL 3

Expert Comment

by:efatihan
ID: 33520181
hello,

this article might help you. i will still continue to look for any remedy.
http://msdn.microsoft.com/en-us/library/aa931253.aspx
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 33520401
as the previous link states, the default is 10 seconds for CeRunAtTime() unless it is implemented differently by the vendor.

you might want to consider the dummy console app that just starts your main exe and then exits.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question