如何判断系统是9x还是NT???NT中,如何用Delphi将系统锁定.(30分)

  • 主题发起人 主题发起人 DJ6674
  • 开始时间 开始时间
D

DJ6674

Unregistered / Unconfirmed
GUEST, unregistred user!
如何判断你的系统是9x还是NT??如果是NT,如何用Delphi将系统锁定.(就是windows2000中的锁定计算机)[?]
 
var lp:TOSVersionInfoA;<br>begin<br>&nbsp; lp.dwOSVersionInfoSize:=SizeOf(lp);<br>&nbsp; GetVersionEx(lp);<br>&nbsp; lp.dwPlatformId; &nbsp; &nbsp; //当前Windows 版本<br>&nbsp; lp.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS;//=TRUE 是windows 95/98/me OS<br>&nbsp; lp.dwPlatformId=VER_PLATFORM_WIN32_NT;//=TRUE 是windows NT及以上的OS<br><br>&nbsp; if lp.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS then begin<br>&nbsp; &nbsp; Case lp.dwMajorVersion of<br>&nbsp; &nbsp; &nbsp; 4: begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Case __Sys_OS_MinorVersion of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 : begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;是Windows95;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (Trim(lp.szCSDVersion)='B') then 是Windows95OSR2;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10:begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 是Windows_98;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Trim(lp.szCSDVersion)='A') then 是Windows98SE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;90:begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 是WindowsME; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; //--------------------------------------------------<br>&nbsp; if lp.dwPlatformId=VER_PLATFORM_WIN32_NT then begin<br>&nbsp; &nbsp; Case lp.dwMajorVersion of<br>&nbsp; &nbsp; &nbsp; 3,4: 是Windows_NT; <br>&nbsp; &nbsp; &nbsp; 5: begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Case __Sys_OS_MinorVersion of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0: 是Windows_2K; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1: 是WindowsXP; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2: 是Windows2003; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>
 
//锁定工作站<br>{不支持 Windows 95/98/Me}<br>{ Loading LockWorkStation dynamically}<br>function LockWS: Boolean;<br>// by Thomas Stutz, SDC<br>type<br>&nbsp; TLockWorkStation = function: Boolean;<br>var<br>&nbsp; hUser32: HMODULE;<br>&nbsp; LockWorkStation: TLockWorkStation;<br>begin<br> Result:=false;<br>&nbsp; &nbsp; // Here we import the function from USER32.DLL<br>&nbsp; &nbsp; hUser32 := GetModuleHandle('USER32.DLL');<br>&nbsp; &nbsp; if hUser32 &lt;&gt; 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; @LockWorkStation := GetProcAddress(hUser32, 'LockWorkStation');<br>&nbsp; &nbsp; &nbsp; if @LockWorkStation &lt;&gt; nil then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; LockWorkStation;<br>&nbsp; &nbsp; &nbsp; &nbsp; Result := True;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;
 
//判断操作系统<br>Procedure GetOSInfo(Var SysName,SysVer:String);<br>var<br>&nbsp;osVerInfo : TOSVersionInfo;<br>&nbsp;majorVer, minorVer ,BuildVer: Integer;<br><br>begin<br>&nbsp;SysName := 'Unknown';<br>{ set operating system type flag }<br>&nbsp;osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);<br>&nbsp;if GetVersionEx(osVerInfo) then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;majorVer := osVerInfo.dwMajorVersion;<br>&nbsp; &nbsp; &nbsp;minorVer := osVerInfo.dwMinorVersion;<br>&nbsp; &nbsp; &nbsp;BuildVer := osVerInfo.dwBuildNumber ;<br>&nbsp; &nbsp; &nbsp;SysVer &nbsp; :=format('%d.%d build %d',[majorVer,minorVer,BuildVer]);<br>&nbsp; &nbsp; &nbsp;case osVerInfo.dwPlatformId of<br>&nbsp; &nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32_NT : { Windows NT/2000 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if majorVer &lt;= 4 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SysName := 'Windows NT'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (majorVer = 5) AND (minorVer= 0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SysName := 'Windows 2000'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (majorVer = 5) AND (minorVer = 1) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SysName := 'Windows XP'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SysName := 'Unknown';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end; {case }<br>&nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32_WINDOWS : { Windows 9x/ME }<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (majorVer = 4) AND (minorVer = 0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SysName := 'Windows 95'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (majorVer = 4) AND (minorVer = 10) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if osVerInfo.szCSDVersion[1] = 'A' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SysName := 'Windows 98 第二版'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SysName := 'Windows 98';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end {if Version = 'A'}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (majorVer = 4) AND (minorVer = 90) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SysName := 'Windows Millenium Edition'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SysName := 'Unknown';<br>&nbsp; &nbsp; &nbsp; &nbsp;end; {case VER_PLATFORM_WIN32_WINDOWS}<br>&nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; SysName := 'Unknown';<br>&nbsp; &nbsp;end;<br>&nbsp;end<br>else<br>&nbsp; SysName := 'Unknown';<br>end;
 
多人接受答案了。
 
后退
顶部