Talk2Tom11 Posted March 4, 2004 Posted March 4, 2004 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 Quote
Aspnot Posted March 4, 2004 Posted March 4, 2004 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. Quote Aspnot
samsmithnz Posted March 4, 2004 Posted March 4, 2004 Why are you limiting your users to Windows XP? Windows XP (Win ver 5.1) is almost the same version as Windows 2000 (Win ver 5.0), and you're not likely to have a very large user base if you only use XP. Quote Thanks Sam http://www.samsmith.co.nz
Talk2Tom11 Posted March 4, 2004 Author Posted March 4, 2004 I know that it is limiting a lot of people... I am not going to end up with only xp user to have access, I am just using this as a sample Quote
Faceless Master Posted March 4, 2004 Posted March 4, 2004 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 Quote Creativity Beyond Imagination http://www.facelessmaster.tk
Administrators PlausiblyDamp Posted March 4, 2004 Administrators Posted March 4, 2004 You could use the environment class to find the version - may be a bit easier (XP is version 5.1) If Environment.OSVersion.Version.Major = 5 AndAlso Environment.OSVersion.Version.Minor = 1 Then 'we are XP End If Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Talk2Tom11 Posted March 4, 2004 Author Posted March 4, 2004 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 Quote
Administrators PlausiblyDamp Posted March 4, 2004 Administrators Posted March 4, 2004 How are you calling the above code then? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Talk2Tom11 Posted March 5, 2004 Author Posted March 5, 2004 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. Quote
Administrators PlausiblyDamp Posted March 5, 2004 Administrators Posted March 5, 2004 How are you starting up the application? Where does the code get called from (Sub Main, Form_Load etc) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders dynamic_sysop Posted March 5, 2004 Leaders Posted March 5, 2004 (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 March 5, 2004 by dynamic_sysop Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.