Here is the code to get the exe instance of a device application.
I have tried this to get solve in 2days , Atlast i got it .I hope this may be help ful to others thatsy i am posting the code
It is self explanatory if any one have doubts please feel free to ask me any doubts in this at below mail id komalinaughty@gmail.com
Imports System.Collections.Generic Imports System.Windows.Forms
_ Private Function CreateEvent(ByVal lpEventAttributes As IntPtr, ByVal bManualReset As Boolean, ByVal bInitialState As Boolean, ByVal lpName As String) As IntPtr End Function
_ Private Function CloseHandle(ByVal hObject As IntPtr) As Boolean End Function
Private Const ERROR_ALREADY_EXISTS As Integer = 183 _ Private Function FindWindow(ByVal className As String, ByVal wndName As String) As IntPtr End Function
''' ''' The main entry point for the application.
'''
' Client Application Entry Point _ Public Sub Main(ByVal args() As String) Dim path As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase Dim handle As IntPtr = CreateEvent(IntPtr.Zero, False, False, path) Dim InvalidHandle As IntPtr = InvalidHandle Dim [error] As Integer = System.Runtime.InteropServices.Marshal.GetLastWin32Error() Dim x As IntPtr Dim y As Integer = 0 x = New IntPtr(y) 'Add Necessary Object declarations and initialization9s)
Try If handle <> InvalidHandle AndAlso ([error] <> ERROR_ALREADY_EXISTS) Then
g_Global = New GlobalClass.GlobalUtils g_InitUtils = New Init.InitUtils Application.Run(New frmLogin) Else Exit Sub End If CloseHandle(handle)
Finally
' Release the Utils Object End Try
End Sub
where in simple windows application we can use both the property and code with Mutex or SingleInstance
Thanks komali
|
No responses found. Be the first to respond and make money from revenue sharing program.
|