powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / Как получить имя операционной системы через API?
2 сообщений из 2, страница 1 из 1
Как получить имя операционной системы через API?
    #35817313
Дмитрий77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Microsoft Windows NT 5.... это следует из GetSystemInfo (kernel32) не годится. Надо чтоб писал "Windows XP" в явном виде. Вообще-то в реестре это параметр "ProductName". Но я уже час в google роюсь, и не могу найти этот простой ответ.
...
Рейтинг: 0 / 0
Как получить имя операционной системы через API?
    #35817362
Дмитрий77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Ну, надо думать они по другому себя не понимают. Еще на это время тратить...Хватит того, что я в исходный код про win2003 словечко вставил, Vista это 6,0, если я правильно мыслю.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
Option Explicit
Private Const VER_PLATFORM_WIN32s =  0 
Private Const VER_PLATFORM_WIN32_WINDOWS =  1 
Private Const VER_PLATFORM_WIN32_NT =  2 

'windows-defined type OSVERSIONINFO
Private Type OSVERSIONINFO
  OSVSize         As Long         'size, in bytes, of this data structure
  dwVerMajor      As Long         'ie NT 3.51, dwVerMajor = 3; NT 4.0, dwVerMajor = 4.
  dwVerMinor      As Long         'ie NT 3.51, dwVerMinor = 51; NT 4.0, dwVerMinor= 0.
  dwBuildNumber   As Long         'NT: build number of the OS
                                  'Win9x: build number of the OS in low-order word.
                                  '       High-order word contains major & minor ver nos.
  PlatformID      As Long         'Identifies the operating system platform.
  szCSDVersion    As String *  128  'NT: string, such as "Service Pack 3"
                                  'Win9x: 'arbitrary additional information'
End Type


'my type for holding the retrieved info
Public Type RGB_WINVER
  PlatformID      As Long
  VersionName     As String
  VersionNo       As String
  ServicePack     As String
  BuildNo         As String
End Type

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

Public Function GetWinVersion(win As RGB_WINVER) As String

'returns a structure (RGB_WINVER)
'filled with OS information

  #If Win32 Then
  
   Dim osv As OSVERSIONINFO
   Dim pos As Integer
   Dim sVer As String
   Dim sBuild As String
   
   osv.OSVSize = Len(osv)
   
   If GetVersionEx(osv) =  1  Then
   
     'PlatformId contains a value representing the OS
      win.PlatformID = osv.PlatformID
     
      Select Case osv.PlatformID
         Case VER_PLATFORM_WIN32s:   win.VersionName = "Win32s"
         Case VER_PLATFORM_WIN32_NT: win.VersionName = "Windows NT"
         
         Select Case osv.dwVerMajor
            Case  4 :  win.VersionName = "Windows NT"
            Case  5 :
            Select Case osv.dwVerMinor
               Case  0 :  win.VersionName = "Windows 2000"
               Case  1 :  win.VersionName = "Windows XP"
               Case  2 :  win.VersionName = "Windows 2003"
            End Select
        End Select
                  
         Case VER_PLATFORM_WIN32_WINDOWS:
         
          'The dwVerMinor bit tells if its 95 or 98.
            Select Case osv.dwVerMinor
               Case  0 :    win.VersionName = "Windows 95"
               Case  90 :   win.VersionName = "Windows ME"
               Case Else: win.VersionName = "Windows 98"
            End Select
         
      End Select
   
   
     'Get the version number
      win.VersionNo = osv.dwVerMajor & "." & osv.dwVerMinor
  
     'Get the build
      win.BuildNo = (osv.dwBuildNumber And &HFFFF&)
       
     'Any additional info. In Win9x, this can be
     '"any arbitrary string" provided by the
     'manufacturer. In NT, this is the service pack.
      pos = InStr(osv.szCSDVersion, Chr$( 0 ))
      If pos Then
         win.ServicePack = Left$(osv.szCSDVersion, pos -  1 )
      End If

   End If
   
  #Else
  
    'can only return that this does not
    'support the 32 bit call, so must be Win3x
     win.VersionName = "Windows 3.x"
  #End If
  
End Function
'----------------------
Private Sub Command18_Click()
   Call GetWinVersion(WinSysVer)
   MsgBox WinSysVer.VersionName
End Sub
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / Как получить имя операционной системы через API?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]