Kompajler ne 'dodaje' nijedan unit u kompajlirani kod, osim system.pas koji sadrzi neke osnovne tipove i funkcije (PChar, TRUE, FALSE, Read(), Write() itd..).
Moze da se izostavi i SysUtils i Registry unit (tako ce kompajlirani program biti mnogo manji - mislim da SysUtils dodaje ~23kb, a Registry unit cak ~70kb).
Umesto Registry klasa se mogu koristiti RegCreateKeyEx, RegSetValueKeyEx, RegQueryValue API-ji..
Malo kasnije cu postovati source.
Velicina kompajlirane verzije je ~15 kb
{$APPTYPE GUI}
uses
Windows;
var
oldState,
newState : String;
hndKey : HKEY;
ValSize : Cardinal;
begin
If RegOpenKeyEx(HKEY_CURRENT_USER,
'Control Panel\Desktop',
0,
KEY_ALL_ACCESS,
hndKey) = ERROR_SUCCESS Then
Begin
RegQueryValueEx(hndKey, 'ScreenSaveActive', nil, nil, nil, @ValSize);
oldState := StringOfChar(' ', ValSize);
RegQueryValueEx(hndKey, 'ScreenSaveActive', nil, nil, PByte(oldState), @ValSize);
newState := Chr(-((Ord(oldState[1]) - 48) - 1) + 48) + #0;
RegSetValueEx(hndKey, 'ScreenSaveActive', 0, REG_SZ, @newState[1], SizeOf(newState));
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, nil, SPIF_SENDWININICHANGE);
MessageBox(0,
PAnsiChar('Screen Saver state was ' + oldState[1] + ', now it is set to ' + newState[1]),
PAnsiChar('Done'),
mb_OK);
End;
end.
[mod::gamzzy] Ne udvajaj poruke!
|