C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Application windows, menus & toolbars »

Device Application - Single instance of the EXE


Posted Date: 04 Nov 2008    Resource Type: Code Snippets    Category: Application windows, menus & toolbars
Author: komaladeviMember Level: Gold    
Rating: 1 out of 5Points: 7



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



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Device Application Single Instance  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Restore Form Size and Position in C#
Previous Resource: Creating an Animated GUI
Return to Discussion Resource Index
Post New Resource
Category: Application windows, menus & toolbars


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use