Solved

Windows mobile application restart

Posted on 2010-08-25
8
1,240 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
recover deleted files by error 37 108
Outlook creates tmp files 2 45
ebay desktop program for windows for a seller who wants to sell alot 2 29
Monitor Resolution 5 25
If your app took Google’s lash recently, here are the 5 most likely reasons.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

777 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