[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Windows mobile application restart

Posted on 2010-08-25
8
Medium Priority
?
1,317 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

650 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