Tema: Detectar SO
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/03/2006, 17:31
Avatar de [EX3]
[EX3]
 
Fecha de Ingreso: marzo-2006
Ubicación: Fuenlabrada, Madrid
Mensajes: 203
Antigüedad: 19 años, 1 mes
Puntos: 1
Para obtener informacion de la version y el nombre de la plataforma incluido añade un modulo a tu proyecto con el siguiente codigo:
Código:
Option Explicit

Public Const ERROR_SUCCESS As Long = 0

Public Const HKEY_LOCAL_MACHINE As Long = &H80000002
Public Const REG_SZ = 1

Public Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128

End Type

Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal HKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal HKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long

Public Function REG_GetString(HKey As Long, Path As String, Key_Name As String) As String
On Local Error Resume Next

Dim keyhand As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf As String
Dim lDataBufSize As Long
Dim intZeroPos As Integer
Dim lValueType As Long

Call RegOpenKey(HKey, Path, keyhand)
lResult = RegQueryValueEx(keyhand, Key_Name, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_SZ Then
    strBuf = String(lDataBufSize, " ")
    lResult = RegQueryValueEx(keyhand, Key_Name, 0&, 0&, ByVal strBuf, lDataBufSize)
    
    If lResult = ERROR_SUCCESS Then
        intZeroPos = InStr(strBuf, Chr$(0))
        If intZeroPos > 0 Then
            REG_GetString = VBA.Left$(strBuf, intZeroPos - 1)
            
        Else
            REG_GetString = strBuf
            
        End If
        
    End If
    
End If

End Function
Añade el siguiente codigo al formulario:
Código:
Option Explicit

Private Sub Form_Load()
Dim Inf As OSVERSIONINFO, VersionName As String, Plataform As String

Me.AutoRedraw = True

Inf.dwOSVersionInfoSize = 148

Call GetVersionEx(Inf)

'Plataformas 9x:
If Inf.dwPlatformId = 1 Then
    Plataform = "9x"
    Inf.dwBuildNumber = Inf.dwBuildNumber And &HFFFF&
    VersionName = REG_GetString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion", "ProductName")
    
'Plataformas NT:
ElseIf Inf.dwPlatformId = 2 Then
    Plataform = "NT"
    VersionName = REG_GetString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion", "ProductName")
        
End If

Print VersionName
Print "Plataforma Windows " & Plataform
Print "Version " & Inf.dwMajorVersion & "." & Inf.dwMinorVersion
Print "Compilacion " & Inf.dwBuildNumber

End Sub
Salu2...
__________________
Proyecto dx_lib32 (http://dxlib32.se32.com) Libreria DLL ActiveX para el desarollo de juegos y programas multimedia en Visual Basic 6.0 con la potencia de DirectX

Dice un dicho que "el que calla otorga". En internet tenemos otro que dice "nunca alimentes a un troll" que viene a decir "dejale hablar solo que se ya se cansara de incordiar". Solo los necios creen tener la razon con la ultima palabra.