/[mldonkey]/mldonkey/src/config/mingw/os_stubs_c.c
ViewVC logotype

Diff of /mldonkey/src/config/mingw/os_stubs_c.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by spiralvoice, Fri Sep 2 22:39:33 2005 UTC revision 1.12 by spiralvoice, Thu Sep 8 12:44:53 2005 UTC
# Line 147  void gettimeofday(struct timeval* p, voi Line 147  void gettimeofday(struct timeval* p, voi
147     return;     return;
148  }  }
149    
150    
151    // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
152    #define BUFSIZE 80
153    
154    void os_uname(char buf[])
155    {
156       OSVERSIONINFOEX osvi;
157       BOOL bOsVersionInfoEx;
158    
159       // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
160       // If that fails, try using the OSVERSIONINFO structure.
161    
162       ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
163       osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
164    
165       if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
166       {
167          osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
168          if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
169             return;
170       }
171    
172       switch (osvi.dwPlatformId)
173       {
174          // Test for the Windows NT product family.
175          case VER_PLATFORM_WIN32_NT:
176    
177          // Test for the specific product.
178          if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
179             strcat(buf, "Microsoft Windows Server 2003, \0");
180    
181          if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
182             strcat(buf, "Microsoft Windows XP \0");
183    
184          if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
185             strcat(buf, "Microsoft Windows 2000 \0");
186    
187          if ( osvi.dwMajorVersion <= 4 )
188             strcat(buf, "Microsoft Windows NT \0");
189    
190          // Test for specific product on Windows NT 4.0 SP6 and later.
191          if( bOsVersionInfoEx )
192          {
193             // Test for the workstation type.
194             if ( osvi.wProductType == VER_NT_WORKSTATION )
195             {
196                if( osvi.dwMajorVersion == 4 )
197                   strcat(buf, "Workstation 4.0 \0" );
198                else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
199                   strcat(buf, "Home Edition \0" );
200                else strcat(buf, "Professional \0" );
201             }
202                
203             // Test for the server type.
204             else if ( osvi.wProductType == VER_NT_SERVER ||
205                       osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
206             {
207                if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
208                {
209                   if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
210                      strcat(buf, "Datacenter Edition \0" );
211                   else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
212                      strcat(buf, "Enterprise Edition \0" );
213                   else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
214                      strcat(buf, "Web Edition \0" );
215                   else strcat(buf, "Standard Edition \0" );
216                }
217                else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
218                {
219                   if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
220                      strcat(buf, "Datacenter Server \0" );
221                   else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
222                      strcat(buf, "Advanced Server \0" );
223                   else strcat(buf, "Server \0" );
224                }
225                else  // Windows NT 4.0
226                {
227                   if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
228                      strcat(buf, "Server 4.0, Enterprise Edition \0" );
229                   else strcat(buf, "Server 4.0 \0" );
230                }
231             }
232          }
233          // Test for specific product on Windows NT 4.0 SP5 and earlier
234          else  
235          {
236             HKEY hKey;
237             char szProductType[BUFSIZE];
238             DWORD dwBufLen=BUFSIZE;
239             LONG lRet;
240    
241             lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
242                "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
243                0, KEY_QUERY_VALUE, &hKey );
244             if( lRet != ERROR_SUCCESS )
245                return;
246    
247             lRet = RegQueryValueEx( hKey, "ProductType", NULL, NULL,
248                (LPBYTE) szProductType, &dwBufLen);
249             if( (lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE) )
250                return;
251    
252             RegCloseKey( hKey );
253    
254             if ( lstrcmpi( "WINNT", szProductType) == 0 )
255                strcat(buf, "Workstation \0" );
256             if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
257                strcat(buf, "Server \0" );
258             if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
259                strcat(buf, "Advanced Server \0" );
260             printf( "%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion );
261          }
262    
263          // Display service pack (if any) and build number.
264                            char tbuf[4096];
265          if( osvi.dwMajorVersion == 4 &&
266              lstrcmpi( osvi.szCSDVersion, "Service Pack 6" ) == 0 )
267          {
268             HKEY hKey;
269             LONG lRet;
270    
271             // Test for SP6 versus SP6a.
272             lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
273                    "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
274                0, KEY_QUERY_VALUE, &hKey );
275             if( lRet == ERROR_SUCCESS )
276                                                                    
277                sprintf(tbuf, "Service Pack 6a (Build %d)\0", osvi.dwBuildNumber & 0xFFFF );        
278             else // Windows NT 4.0 prior to SP6a
279             {
280                sprintf(tbuf, "%s (Build %d)\0",
281                   osvi.szCSDVersion,
282                   osvi.dwBuildNumber & 0xFFFF);
283             }
284             RegCloseKey( hKey );
285          }
286          else // not Windows NT 4.0
287          {
288             sprintf(tbuf, "%s (Build %d)\0", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
289          }
290    
291          strcat(buf, tbuf);
292          break;
293    
294          // Test for the Windows Me/98/95.
295          case VER_PLATFORM_WIN32_WINDOWS:
296    
297          if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
298          {
299              strcat (buf, "Microsoft Windows 95 ");
300              if (osvi.szCSDVersion[1]=='C' || osvi.szCSDVersion[1]=='B')
301                 strcat(buf, "OSR2 \0" );
302          }
303    
304          if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
305          {
306              strcat(buf, "Microsoft Windows 98 ");
307              if ( osvi.szCSDVersion[1] == 'A' )
308                 strcat(buf, "SE \0" );
309          }
310    
311          if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
312          {
313              strcat(buf, "Microsoft Windows Millennium Edition\0");
314          }
315          break;
316    
317          case VER_PLATFORM_WIN32s:
318    
319          strcat(buf, "Microsoft Win32s\0");
320          break;
321       }
322       return;
323    }
324    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26