Windows Service having UI form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Asutosha
    New Member
    • Sep 2007
    • 2

    Windows Service having UI form

    Hi,
    i want to create a Windows Service which will starts autometically when windows OS starts.
    it will show a Login form.
    if you give correct username and password it will do nothing
    else
    if will delete a pre-define folder..

    i search in the website and codeproject also.
    i di not find any proper solution, please some one help me to solve this problem.

    regards
    Asutosha
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    There are a couple of things you have to do here - you have to set up the service so that it can interact with the desktop. This is done in the service applet in Control Panel/Administrative Tools.
    • Double click the service to open it
    • Select the Log On tab
    • Make sure the service is set to "Local System Account" (otherwise it cannot interact with the desktop"
    • Check "Allow service to interact with desktop"


    Now, in your service onstart event, new up your login form:

    Code:
    Dim MyLoginForm as new frmLogin '(or whatever its called)
    Dim ValidUser As Boolean = False
    
    If MyLoginForm.ShowDialog() = vbOK Then
           'Check username/password, set ValidUser
    End If
    
    If Not ValidUser Then
          'Do what you have to in order to delete the folder
    End If
    
    MyLoginForm.Close

    Comment

    Working...