Hello,
Would anyone happen to know how to force a single instance of a Console application on a Pocket PC (IPAQ) using vb.net (Visual Studio 2008)? I have been bouncing my head off the wall on this one. I just can't seem to grasp it! I have tried the mutex way but it does not seem to be working. Below is the code I have been trying to get to work.

Code:
'This is the Class
Imports System
Imports System.Runtime.InteropServices
Imports System.Reflection

Public Class OneInstance

    Private Const ERROR_ALREADY_EXISTS As Integer = 183

    <DllImport("CoreDll.Dll")> Private Shared Function GetLastError() As Integer
    End Function
    <DllImport("CoreDll.Dll", EntryPoint:="CreateMutexW")> Private Shared Function CreateMutex(ByVal lpMutexAttributes As IntPtr, ByVal InitialOwner As Boolean, ByVal MutexName As String) As Integer
    End Function

    Public Function IsInstanceRunning() As Boolean
        Dim applicationname As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name()
        If CreateMutex(IntPtr.Zero, True, applicationname) <> 0 Then
            Return Marshal.GetLastWin32Error() = ERROR_ALREADY_EXISTS
        Else
        End If
        Return False
    End Function
End Class
Code:
'This is how I am calling it inside of the module
Imports System
Imports System.Xml
Imports System.Diagnostics

Module Module1
    Sub Main()
        On Error Resume Next
Dim a As New OneInstance
        If a.IsInstanceRunning() Then
'End the second, third, etc process            
Process.GetCurrentProcess().Dispose()
        End If
           ' Continue on with the rest of the code
      End Sub
End Module
Any comments and or help is appreciated!
Thanks,
Jlynn001