Monday, 6 May 2013

how to determine 32 bit or 64 bit in vb6 or Visual Basic 6

Private Function Registry_Read(Key_Path, Key_Name) As Variant
      On Error Resume Next
       Dim Registry As Object
       Set Registry = CreateObject("WScript.Shell")
       Registry_Read = Registry.RegRead(Key_Path & Key_Name)
   End Function

' This  function read the value from registry editor

Private Sub Test()
    'Type-1
     MsgBox Registry_Read("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows  \CurrentVersion\", "ProgramFilesDir (x86)")
    'if 64 bit it will return the path name
    'if 32bit  , it will return empty string
    'from this we can identify 32 bit or 64 bit.

   
   
    'Type-2
           Dim sak As String
     sak = Registry_Read("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\", "Identifier")
     If InStr(1, sak , "64") Then
        MsgBox "Its 64 bit version !", vbInformation, "BASE"
       ' Write code as you want
     ElseIf InStr(1,sak , "x86") Then
        MsgBox "Its 32 bit version !", vbInformation, "BASE"
             ' Write code as you want
     End If
End Sub


Call the Test function. For example call the test function in Form Load event! with your own risk
I was collected this information in webpages!

No comments:

Post a Comment