Windows Develop Bookmark and Share   
 index > Windows Forms General > is it possible to restrict qty of app instances that client can open
 

is it possible to restrict qty of app instances that client can open

hiya,
I have my EXE on the server, and the clients are using it via a shortcut which points to the exe.

Is it possible to restrict the app so that machineA cannot open a MULTIPLE consecutive instances of the app?

many thanks, 
yogi
MigrationUser 1  Friday, May 06, 2005 6:45 AM

Yes, you can instruct the app not to load more than one instance at a time. 

See my blog post[1] for details and discussion.

Hope that helps,

-Paul


[1] http://www.codebetter.com/blogs/paul.laudeman/archive/2004/07/17/19576.aspx
MigrationUser 1  Sunday, May 08, 2005 8:02 PM
Try this:

#Region "Previous Existance Function"

    Private Function PrevInstance() As Boolean
        If UBound(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
            Return True
        Else
            Return False
        End If
    End Function

#End Region

-----------------------------

Then in Form_LOad():

        If PrevInstance() = True Then
            MessageBox.Show("The application is already running. Press OK to exit", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End
        End If

----------------------------

You must use 'End' if a previous existance is found, as 'Application.Exit()' shows the form briefly when you click ok to the MessageBox & 'End' doesn't.

I hope this helps
MigrationUser 1  Monday, May 09, 2005 3:59 AM
thanks folks,

It worked a treat :-)

yogi
MigrationUser 1  Monday, May 09, 2005 11:32 AM

You can use google to search for other answers

Custom Search

More Threads

• Get lastest version .Net Framework Directory
• accessing windows components from class
• I am getting this error in my code .The type or namespace name could not be found (are you missing a using directive or an assembly reference?) How to fix this?
• Pocket PC Emulator and connections to webservices...
• Size of MDI Children after unmaximize
• ListView Export To Excel
• Auto-Expanding Controls/Textbox?
• How to embed child datagrid into its parent in windows forms
• Show folder's conetents in listview
• Applying LinearGradientBrush on a TextBox