Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am having a little problem... I wrote a code to check if the computer is running windows xp, and if it is, then go through to the program, if not then give a messagebox error. But the problem is, if you are not running it, and wait a few seconds after the messagebox has been displayed, the main form will popup. here is my code

 

Private Sub Start_Check_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim myKey As Microsoft.Win32.RegistryKey
       Dim strLocation As String
       Dim strKey As String

       strLocation = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
       strKey = "ProductName"

       myKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strLocation)
       If myKey.GetValue(strKey) = "Microsoft Windows XPh" Then
           fL.ShowDialog(Me)
       Else
           MessageBox.Show("You are Running " & myKey.GetValue(strKey) & ".  " & " You Must Run Windows XP or Higher", "Windows Version Check", MessageBoxButtons.OK, MessageBoxIcon.Error)
           Me.Close()
       End If
       myKey.Close()
   End Sub

Posted

Is that the first thing that the application does? If so...

 

It looks like this code is from a form. Try moving it to a Sub Main in a module and do something like this:

 

If XP then
   load your form
End If

 

This means that the form will only be loaded if the user is running XP.

Aspnot
Posted

hmm..well hope this helps.Coded in Vb6 by me.

Function GetAttributes(Filename As String)

On Error Resume Next

Dim Result As String, Attribte As Long

Attribte = GetAttr(Filename)

If Attribte And vbHidden Then

Result = MsgBox("This program is for Win98", vbExclamation, "Error")

ElseIf Dir(Filename) = Empty Then

Result = MsgBox("This program is for Win95", vbExclamation, "Error")

Else

Result = MsgBox("This program is for WinXP", vbExclamation, "Error")

End If

End

End Function

Private Sub Form_Load()

Call GetAttributes("C:\autoexec.bat")

End Sub

Creativity Beyond Imagination

http://www.facelessmaster.tk

Posted
the fact of checking if it is xp or not is not my problem... I am having a problem with, even though the messagebox pops up when it is not xp, the program still opens and I don't know what I did in my code to cause that
Posted
What do you mean? The code up top is what I used... and the checking part works... but when it isn't the right version, it gives the messagebox, but also eventually goes into the app.
  • Leaders
Posted (edited)

try this ....

   Private Sub Start_Check_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       Dim version As Double = Environment.OSVersion.Version.Major & "." & Environment.OSVersion.Version.Minor
       Dim OperatingSystem As String = Environment.OSVersion.Platform.ToString

       If OperatingSystem = "Win32NT" AndAlso version = 5.1 Then
           Console.WriteLine("You are running Windows XP")
           '/// let application run
       Else
           MessageBox.Show("You are running an Invalid version of OS , this Application will now terminate" _
           , Convert.ToString(OperatingSystem & " - " & version), MessageBoxButtons.OK, MessageBoxIcon.Error)
           MyBase.Close()
       End If

   End Sub

Edited by dynamic_sysop

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...