02-09-2009, 05:22 PM
في البداية السلام عليكم
Total Physical Memory
Total Page Memory
Available Page Memory
Available Physical Memory
Available Virtual Memory
Memory Used Percentage
Application Is Responding
App Exec
App Restart
Exec And Wait
App Maximize
App Minimize
Caps Lock State
Shift State
Insert State
Num Lock State
Contrl State
Delete State
كود :
function TotalPhysicalMemory: Int64;
var
MemStat: TMemoryStatus;
begin
MemStat.dwLength := SizeOf(MemStat);
GlobalMemoryStatus(MemStat);
result := MemStat.dwTotalPhys;
end;Total Page Memory
كود :
function TotalPageMemory: Int64;
var
MemStat: TMemoryStatus;
begin
MemStat.dwLength := SizeOf(MemStat);
GlobalMemoryStatus(MemStat);
result := MemStat.dwTotalPageFile;
end;Available Page Memory
كود :
function AvailablePageMemory: Int64;
var
MemStat: TMemoryStatus;
begin
MemStat.dwLength := SizeOf(MemStat);
GlobalMemoryStatus(MemStat);
result := MemStat.dwAvailPageFile;
end;Available Physical Memory
كود :
function AvailablePhysicalMemory: Int64;
var
MemStat: TMemoryStatus;
begin
MemStat.dwLength := SizeOf(MemStat);
GlobalMemoryStatus(MemStat);
result := MemStat.dwAvailPhys;
end;Available Virtual Memory
كود :
function AvailableVirtualMemory: Int64;
var
MemStat: TMemoryStatus;
begin
MemStat.dwLength := SizeOf(MemStat);
GlobalMemoryStatus(MemStat);
result := MemStat.dwAvailVirtual;
end;Memory Used Percentage
كود :
function MemoryUsedPercentage: Integer;
var
MemStat: TMemoryStatus;
begin
MemStat.dwLength := SizeOf(MemStat);
GlobalMemoryStatus(MemStat);
result := MemStat.dwMemoryLoad;
end;Application Is Responding
كود :
function AppIsResponding(const ClassName: string; const TimeOut: Cardinal): Boolean;
var
Res: DWORD;
h: HWND;
bClassFound,
bSendMessage: Boolean;
begin
bSendMessage := FALSE;
h := FindWindow(PChar(ClassName), nil);
bClassFound := (h <> 0);
if bClassFound then
bSendMessage := (SendMessageTimeout(H,
WM_NULL,
0,
0,
SMTO_NORMAL or SMTO_ABORTIFHUNG,
TIMEOUT,
Res) <> 0);
result := (bClassFound and bSendMessage);
endApp Exec
كود :
function AppExec(const CmdLine, CmdParams: string; const CmdShow: Integer): Boolean;
begin
result := (ShellExecute(GetCurrentProcess,
'open',
PChar(CmdLine),
PChar(CmdParams),
'',
CmdShow) > 32);
end;App Restart
كود :
procedure AppRestart;
begin
AppExec(ParamStr(0), '', SW_SHOW); // <<-- Function AppExec is here
TerminateProcess(GetCurrentProcess, 0);
end;Exec And Wait
كود :
uses ShellAPI;
procedure ExecAndWait(const FileName, Params: string; const CmdShow: Integer);
var
exInfo: TShellExecuteInfo;
Ph: DWORD;
begin
FillChar(exInfo, SizeOf(exInfo), 0);
with exInfo do
begin
cbSize := SizeOf(exInfo);
fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
Wnd := GetActiveWindow();
ExInfo.lpVerb := 'open';
ExInfo.lpParameters := PChar(Params);
lpFile := PChar(FileName);
nShow := CmdShow;
end;
if ShellExecuteEx(@exInfo) then
Ph := exInfo.HProcess
else
begin
ShowMessage(SysErrorMessage(GetLastError));
Exit;
end;
while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do
ProcessMessages;
CloseHandle(Ph);
end;App Maximize
كود :
procedure AppMaximize(hWin: HWND);
begin
SendMessage(hWin, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
end;App Minimize
كود :
procedure AppMinimize(hWin: HWND);
begin
SendMessage(hWin, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;Caps Lock State
كود :
function CapsLockState: Bool;
var
KS: TKeyboardState;
begin
GetKeyboardState(KS);
if bool(ks[020]) then Result := True else Result := False;
end;Shift State
كود :
function ShiftState: BOOL;
var
KS: TKeyboardState;
begin
GetKeyboardState(KS);
if bool(ks[016]) then Result := True else Result := False;
end;Insert State
كود :
function InsertState: BOOL;
var
KS: TKeyboardState;
begin
GetKeyboardState(KS);
if bool(ks[045]) then Result := True else Result := False;
endNum Lock State
كود :
function NumLockState: BOOL;
var
KS: TKeyboardState;
begin
GetKeyboardState(KS);
if bool(ks[144]) then Result := True else Result := False;
end;Contrl State
كود :
function ContrlState: BOOL;
var
KS: TKeyboardState;
begin
GetKeyboardState(KS);
if bool(ks[017]) then Result := True else Result := False;
end;Delete State
كود :
function DeleteState: BOOL;
var
KS: TKeyboardState;
begin
GetKeyboardState(KS);
if bool(ks[046]) then Result := True else Result := False;
end; و السلام.

