home *** CD-ROM | disk | FTP | other *** search
- unit UWinEnv;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs;
-
- type
- TWinEnv = class(TComponent)
- private
- { Private declarations }
- FWinDir: String;
- FSysDir: String;
- FSWidth: longint;
- FSHeight: longint;
- FColorDepth: integer;
- procedure SetWinDir(Value: string);
- procedure SetSysDir(Value: string);
- procedure SetSWidth(Value: longint);
- procedure SetSHeight(Value: longint);
- procedure SetColorDepth(Value: integer);
- protected
- { Protected declarations }
- public
- { Public declarations }
- constructor Create(AOwner: TComponent); override;
- published
- { Published declarations }
- property WindowsDir: string read FWinDir write SetWinDir;
- property SystemDir: string read FSysDir write SetSysDir;
- property ScreenWidth: longint read FSWidth write SetSWidth;
- property ScreenHeight: longint read FSHeight write SetSHeight;
- property ColorDepth: integer read FColorDepth write SetColorDepth;
- end;
-
- procedure Register;
-
- implementation
-
- procedure Register;
- begin
- RegisterComponents('Add Ons', [TWinEnv]);
- end;
-
- constructor TWinEnv.Create(AOwner: TComponent);
- var
- szWindows: PChar;
- szSystem: PChar;
- BitsPerPlane: integer;
- ColorPlanes: integer;
- BitsPerPixel: integer;
- TempHandle: HWND;
- TempDC: HDC;
- begin
- inherited Create(AOwner);
-
- {Set the WinDir Property}
- szWindows := strAlloc(255);
- GetWindowsDirectory(szWindows, 255);
- FWinDir := strPas(szWindows);
- strDispose(szWindows);
-
- {Set the SysDir Property}
- szSystem := strAlloc(255);
- GetSystemDirectory(szSystem, 255);
- FSysDir := strPas(szSystem);
- strDispose(szSystem);
-
- {Set the SysDir Property}
- FSWidth := Screen.Width;
-
- {Set the SysDir Property}
- FSHeight := Screen.Height;
-
- {Get the Color Depth of the Device}
- TempHandle:= Application.Handle;
- TempDC := GetDC(TempHandle);
- BitsPerPlane := GetDeviceCaps(TempDC, BITSPIXEL);
- ColorPlanes := GetDeviceCaps(TempDC, PLANES);
- BitsPerPixel := BitsPerPlane * ColorPlanes;
- if ReleaseDC(TempHandle, TempDC) <> 1 then
- messagedlg('DC not released', mtInformation, [mbOk],0);
- FColorDepth := BitsPerPixel;
-
- end;
-
- procedure TWinEnv.SetWinDir(Value: string);
- begin
- if FWinDir <> Value then
- FWinDir := Value;
- end;
-
- procedure TWinEnv.SetSysDir(Value: string);
- begin
- if FSysDir <> Value then
- FSysDir := Value;
- end;
-
- procedure TWinEnv.SetSWidth(Value: longint);
- begin
- if FSWidth <> Value then
- FSWidth := Value;
- end;
-
- procedure TWinEnv.SetSHeight(Value: longint);
- begin
- if FSHeight <> Value then
- FSHeight := Value;
- end;
-
- procedure TWinEnv.SetColorDepth(Value: integer);
- begin
- if FColorDepth <> Value then
- FColorDepth := Value;
- end;
-
- end.
-