Results 1 to 4 of 4

Thread: better way

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    better way

    what is a better way to write this, i want it to be able to read the file, then replace the text in the file.

    VB Code:
    1. Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
    2.         IO.File.Delete("dtmbuffer.txt")
    3.         IO.File.Copy("dtm.txt", "dtmbuffer.txt")
    4.         Dim dtm As IO.StreamReader = IO.File.OpenText("dtmbuffer.txt")
    5.         Dim dtm2 As IO.StreamWriter = IO.File.AppendText("dtm.txt")
    6.         Try
    7.             Select Case dtm.ReadLine()
    8.                 Case Is = 1
    9.                     MsgBox("Task Manager is already disabled.")
    10.                     Me.Close()
    11.                 Case Is = 0
    12.                     Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Policies\System")
    13.                     Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Policies\System", True).SetValue("disabletaskmgr", "1")
    14.                     dtm2.WriteLine("1")
    15.                     MsgBox("Task Manager is now disabled.")
    16.                     Me.Close()
    17.             End Select
    18.  
    19.         Catch ex As Exception
    20.  
    21.         End Try
    22.     End Sub
    "Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: better way

    Why don't you query the registry to begin with, rather than depending on a text file?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    Re: better way

    very very good idea, thanks
    "Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    Re: better way

    how can i check the presense of something in the registry?
    "Anybody can get angry or sad and frown but it takes a person with character to smile when times are hard."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width