Windows жойлашган папкани (йўлни) аниқлаш
Биринчи усул
public
{ Public declarations }
Windir: string;
WindirP: PChar;
Res: Cardinal;
procedure TForm1.Button1Click(Sender: TObject);
begin
WinDirP := StrAlloc(MAX_PATH);
Res := GetWindowsDirectory(WinDirP, MAX_PATH);
if Res > 0 then
WinDir := StrPas(WinDirP);
Label1.Caption := WinDir;
end;
Иккинчи усул
{$IFNDEF WIN32}
const MAX_PATH = 144;
{$ENDIF}
...
implementation
...
var
a : array[0..MAX_PATH] of char;
begin
GetWindowsDirectory(a, sizeof(a));
ShowMessage(StrPas(a));
GetSystemDirectory(a, sizeof(a));
ShowMessage(StrPas(a));
Windows версиясини аниқлаш.
type
TWinVersion = (wvUnknown, wv95, wv98, wvME, wvNT3, wvNT4, wvW2K, wvXP);
function DetectWinVersion: TWinVersion;
var
OSVersionInfo: TOSVersionInfo;
begin
Result := wvUnknown;
OSVersionInfo.dwOSVersionInfoSize := sizeof(TOSVersionInfo);
if GetVersionEx(OSVersionInfo) then
begin
case OSVersionInfo.DwMajorVersion of
3: Result := wvNT3;
4: case OSVersionInfo.DwMinorVersion of
0: if OSVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then
Result := wvNT4
else
Result := wv95;
10: Result := wv98;
90: Result := wvME;
end;
5: case OSVersionInfo.DwMinorVersion of
0: Result := wvW2K;
1: Result := wvXP;
end;
end;
end;
end;
Do'stlaringiz bilan baham: |