Outline · Standard · [ Linear+ ]

> Windows Xp Trikowi, Owo je ipak zanimljivije i korisnije...

NeverMore21
post Dec 29 2006, 09:58 PM
Post #1





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



E owako...Poshto su se swi wec smorili sa tipichnim algoritmima vezanih za brojeve, stringowe, nizowe itd. (zadaci sa bloka), ewo nove teme koja ce valjda biti zanimljivija i ne bash tako monotona! Swi koji hoce (i znaju) neka owde postuju funkcije i procedure vezane za Windows XP (znaci pre svega Win API)!!! I bez funkicja tipa: kako dobiti 3. znak iz verzije Service Pack-a, i slicno!!! Za pocetak, postovacu neke korisne funkcije i procedure!!! Ali u drugom postu!!! Pozzzz


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
 
Reply to this topicStart new topicStart Poll
Replies(1 - 15)
NeverMore21
post Dec 29 2006, 10:29 PM
Post #2





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



Za pocetak, ewo funkcije koja otwara CD-ROM DRIVE:

CODE

uses MMSystem;

procedure OpenCDRom;
begin
mciSendString ('Set cdaudio door open wait', nil, 0, handle);
end;


i naravno funkcija koja zatwara CD-ROM DRIVE:

CODE

uses MMSystem;

procedure CloseCDRom;
begin
mciSendString('Set cdaudio door closed wait', nil, 0, handle);
end;



Idemo dalje; Sledeca funkcija upravlja prikazivanjem sata na taskbaru. Znaci, ako
vam je sat dosadio, samo pozowite owu funkciju:


CODE

function ShowTrayClock(bValue: Boolean) : Boolean;
var
 TrayWnd, TrayNWnd, ClockWnd: HWND;
begin
 TrayWnd  := FindWindow('Shell_TrayWnd', nil);
 TrayNWnd := FindWindowEx(TrayWnd, 0, 'TrayNotifyWnd', nil);
 ClockWnd := FindWindowEx(TrayNWnd, 0, 'TrayClockWClass', nil);
 Result := IsWindow(ClockWnd);
 if Result then
 begin
   ShowWindow(ClockWnd, Ord(bValue));
   PostMessage(ClockWnd, WM_PAINT, 0, 0);
 end;
end;



Ipak, ako zelite da sakrijete taskbar, ew wam reshenja:

CODE

procedure ShowTaskBar(show: boolean);
begin
if show=true then
ShowWindow(FindWindow('Shell_TrayWnd',nil), SW_SHOWNA); end else
        ShowWindow(FindWindow('Shell_TrayWnd',nil), SW_HIDE);
end;



Ako neko BASH woli da se igra sa ikonicama ewo mu procedure za skriwanje desktop ikonica:
CODE

procedure ShowDesktopIcons(const Show: boolean);
var h : THandle;
begin
h := FindWindow('ProgMan', nil);
h := GetWindow(h, GW_CHILD);
if Show = True then
 ShowWindow(h, SW_SHOW)
else
  ShowWindow(h, SW_HIDE);
end;


Dobro, dosta sa sakrivanjem swega i swacega (ipak ima tu josh dosta toga biggrin.gif). Sledeca procedura zamenjuje akcije levog i desnog dugmeta na mishu:
CODE

procedure SwapMouseButtons(bValue: Boolean);
begin
 if bValue then
   SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 1, nil, 0)
 else
   SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 0, nil, 0);
end;



Hocete da pravite probleme biggrin.gif, onda ewo koda za iskljucivanje task manager-a:
CODE

uses
 Registry;

procedure EnableCTRLALTDEL(YesNo : boolean);
const
sRegPolicies = '\Software\Microsoft\Windows\CurrentVersion\Policies';
begin
 with TRegistry.Create do
 try
   RootKey:=HKEY_CURRENT_USER;
   if OpenKey(sRegPolicies+'\System\',True) then
   begin
     case YesNo of
       False:
         begin
           WriteInteger('DisableTaskMgr',1);
         end;
       True:
         begin
           WriteInteger('DisableTaskMgr',0);
         end;
     end;
   end;
   CloseKey;
   if OpenKey(sRegPolicies+'\Explorer\',True) then
   begin
     case YesNo of
       False:
         begin
           WriteInteger('NoChangeStartMenu',1);
           WriteInteger('NoClose',1);
           WriteInteger('NoLogOff',1);
         end;
       True:
         begin
           WriteInteger('NoChangeStartMenu',0);
           WriteInteger('NoClose',0);
           WriteInteger('NoLogOff',0);
         end;
     end;
   end;
   CloseKey;
 finally
   Free;
 end;
end;


Ako hocete da zeznete profesora, sledecim kodom mozete ugasiti monitor:
CODE

SendMessage(Application.Handle, wm_SysCommand, Windows.SC_MONITORPOWER, 1); {gasi monitor}
SendMessage(Application.Handle, wm_SysCommand, Windows.SC_MONITORPOWER, -1); {pali monitor}


Ewo i koda za igranje sa tastaturom. Njime mozete upravljati (gasiti i paliti) LED diodama na tastaturi:

CODE

procedure SetLedState(KeyCode: TKeyType; bOn: Boolean);
var
 KBState: TKeyboardState;
 Cod: Byte;
begin
 case KeyCode of
   ktScrollLock: Cod := VK_SCROLL;
   ktCapsLock: Cod := VK_CAPITAL;
   ktNumLock: Cod := VK_NUMLOCK;
 end;
 GetKeyboardState(KBState);
 if (Win32Platform = VER_PLATFORM_WIN32_NT) then
 begin
   if Boolean(KBState[Cod]) <> bOn then
   begin
     keybd_event(Cod,
                 MapVirtualKey(Cod, 0),
                 KEYEVENTF_EXTENDEDKEY,
                 0);

     keybd_event(Cod,
                 MapVirtualKey(Cod, 0),
                 KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,
                 0);
   end;
 end
 else
 begin
   KBState[Cod] := Ord(bOn);
   SetKeyboardState(KBState);
 end;
end;




biggrin.gif Uh smorih se!!! Odoh sad neshto da radim, a sutra cu da postujem josh biggrin.gif:D!!!
Narawno, sve je otworeno za pitanja! biggrin.gif Swako ko ima neki dobar kod nek ga postuje biggrin.gif! Pozzzz

P.S. Utrnushe mi prsti biggrin.gif! Srecna NG cheers.gif !


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
RZA
post Dec 29 2006, 10:38 PM
Post #3


Njeno Ljubičanstvo


Group: Članovi
Joined: 7-September 06
Member No.: 92
Status: Bivši učenik MGa



ok.. lepo je to.. lepo je znati... ali koj ce mi to? XD.gif..
neke mogu da uradim sa jednostavnih par klikova.. ali dobro.. smile.gif..
ponavljam lepo je znati.. nastavi.. mozda dodje nesto stvarno stvarno dobro..


--------------------
cold
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
NeverMore21
post Dec 29 2006, 10:46 PM
Post #4





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



Pa dobro, nije da mi je dosadno ali ewo me 05! Postowacu josh par korisnih kodowa. Pa da pochnem:

Sledeca funkcija uslikawa trenutnu sliku ekrana i wratja je kao tip TBitmap (samo je dodelite Image-u):
CODE

function GetScreenShot: TBitmap;
var
 Desktop: HDC;
begin
 Result  := TBitmap.Create;
 Desktop := GetDC(0);
 try
   try
     Result.PixelFormat := pf32bit;
     Result.Width := Screen.Width;
     Result.Height := Screen.Height;
     BitBlt(Result.Canvas.Handle, 0, 0, Result.Width, Result.Height, Desktop, 0, 0, SRCCOPY);
     Result.Modified := True;
   finally
     ReleaseDC(0, Desktop);
   end;
 except
   Result.Free;
   Result := nil;
 end;
end;



Sledecom funkicjom proverawate da li je trenutno ulogovani korisnik administrator:
CODE

const
 SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority =
   (Value: (0, 0, 0, 0, 0, 5));
 SECURITY_BUILTIN_DOMAIN_RID = $00000020;
 DOMAIN_ALIAS_RID_ADMINS = $00000220;

function IsAdmin: Boolean;
var
 hAccessToken: THandle;
 ptgGroups: PTokenGroups;
 dwInfoBufferSize: DWORD;
 psidAdministrators: PSID;
 x: Integer;
 bSuccess: BOOL;
begin
 Result   := False;
 bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True,
   hAccessToken);
 if not bSuccess then
 begin
   if GetLastError = ERROR_NO_TOKEN then
     bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY,
       hAccessToken);
 end;
 if bSuccess then
 begin
   GetMem(ptgGroups, 1024);
   bSuccess := GetTokenInformation(hAccessToken, TokenGroups,
     ptgGroups, 1024, dwInfoBufferSize);
   CloseHandle(hAccessToken);
   if bSuccess then
   begin
     AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2,
       SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
       0, 0, 0, 0, 0, 0, psidAdministrators);
     {$R-}
     for x := 0 to ptgGroups.GroupCount - 1 do
       if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then
       begin
         Result := True;
         Break;
       end;
     {$R+}
     FreeSid(psidAdministrators);
   end;
   FreeMem(ptgGroups);
 end;
end;




Hocete iz programa da ispraznite Recycle Bin, ewo reshenja:
CODE

procedure EmptyRecycleBin;
const
 SHERB_NOCONFIRMATION = $00000001;
 SHERB_NOPROGRESSUI = $00000002;
 SHERB_NOSOUND = $00000004;
type
 TSHEmptyRecycleBin = function(Wnd: HWND;
                               pszRootPath: PChar;
                               dwFlags: DWORD): HRESULT;  stdcall;
var
 SHEmptyRecycleBin: TSHEmptyRecycleBin;
 LibHandle: THandle;
begin
 LibHandle := LoadLibrary(PChar('Shell32.dll'));
 if LibHandle <> 0 then @SHEmptyRecycleBin :=
     GetProcAddress(LibHandle, 'SHEmptyRecycleBinA')
 else
 begin
   MessageDlg('Failed to load Shell32.dll.', mtError, [mbOK], 0);
   Exit;
 end;

 if @SHEmptyRecycleBin <> nil then
   SHEmptyRecycleBin(Application.Handle,
                     nil,
                     SHERB_NOCONFIRMATION or SHERB_NOPROGRESSUI or SHERB_NOSOUND);
 FreeLibrary(LibHandle); @SHEmptyRecycleBin := nil;
end;




I ewo, za danas josh jedan kod kojim mozete da upravljate jachinom zwuka media plejera:
CODE

uses
 MPlayer, MMSystem;
const
 MCI_SETAUDIO = $0873;
 MCI_DGV_SETAUDIO_VOLUME = $4002;
 MCI_DGV_SETAUDIO_ITEM = $00800000;
 MCI_DGV_SETAUDIO_VALUE = $01000000;
 MCI_DGV_STATUS_VOLUME = $4019;
type
 MCI_DGV_SETAUDIO_PARMS = record
   dwCallback: DWORD;
   dwItem: DWORD;
   dwValue: DWORD;
   dwOver: DWORD;
   lpstrAlgorithm: PChar;
   lpstrQuality: PChar;
 end;
type
 MCI_STATUS_PARMS = record
   dwCallback: DWORD;
   dwReturn: DWORD;
   dwItem: DWORD;
   dwTrack: DWORD;
 end;

procedure SetMPVolume(MP: TMediaPlayer; Volume: Integer);
 { Volume: 0 - 1000 }
var
 p: MCI_DGV_SETAUDIO_PARMS;
begin
 { Volume: 0 - 1000 }
 p.dwCallback := 0;
 p.dwItem := MCI_DGV_SETAUDIO_VOLUME;
 p.dwValue := Volume;
 p.dwOver := 0;
 p.lpstrAlgorithm := nil;
 p.lpstrQuality := nil;
 mciSendCommand(MP.DeviceID, MCI_SETAUDIO,
   MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, Cardinal(@p));
end;



Eto, waljda ce nekom koristiti... biggrin.gif ... Odoh sad malo na Rise of Nations biggrin.gif tongue.gif ! Pozzz


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
NeverMore21
post Dec 29 2006, 10:50 PM
Post #5





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



Pa waljda nekom zatreba biggrin.gif!!! Od owoga se pocinje graditi program, a posle swe ostalo biggrin.gif... Pa sad ne znam shta je to stwarno stwarno dobro...Necu valjda da pishem kako da oborish sistem kad to moze u 2 reda biggrin.gif...(ili ipak jedan)! U swakom slucaju hwala na kritici, pokusacu da nadjem neshto 'korisnije' biggrin.gif


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
pyost
post Dec 29 2006, 10:51 PM
Post #6


Deus Ex Makina
Group Icon

Group: Administratori
Joined: 25-January 06
From: Beograd
Member No.: 2
Status: Bivši učenik MGa
Škola/Razred: RAF



Svaka cast za temu i kodove clap.gif


--------------------
Baby, it's a violent world.

Registrovani korisnik Linuxa broj 460770 [Ubuntu 7.10]
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
NeverMore21
post Dec 29 2006, 10:53 PM
Post #7





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



Hwala na podrshci biggrin.gif! Da se bar nekom swidi biggrin.gif


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bone_fletcher
post Dec 29 2006, 11:29 PM
Post #8





Group: Članovi
Joined: 29-December 06
From: Beograd
Member No.: 328
Status: Van MGa
Ime i prezime: Igor Škarić
Škola/Razred: Nikola Tesla IV/8



QUOTE(nevermore @ Dec 29 2006, 11:50 PM)
Pa waljda nekom zatreba biggrin.gif!!! Od owoga se pocinje graditi program, a posle swe ostalo biggrin.gif... Pa sad ne znam shta je to stwarno stwarno dobro...Necu valjda da pishem kako da oborish sistem kad to moze u 2 reda biggrin.gif...(ili ipak jedan)! U swakom slucaju hwala na kritici, pokusacu da nadjem neshto 'korisnije' biggrin.gif
*




Bojane svaka cast za temu,ukljucicu se i ja u nju.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Eli0t
post Dec 29 2006, 11:47 PM
Post #9


Voodoo People
Group Icon

Group: Administratori
Joined: 25-January 06
Member No.: 1
Status: Bivši učenik MGa



Lepo.. A jel bi mogao da postujes izvor odakle si uzeo sve ovo (u slucaju da si copy/pasteovao sa neta..) ?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Iva
post Dec 30 2006, 09:17 AM
Post #10





Group: Članovi
Joined: 30-June 06
Member No.: 71
Status: Van MGa





--------------------
When life throws you lemons... genetically re-engineer the lemon tree to eliminate taste compatibility issues, using the profits to increase personal gain and eventually dominate the citrus market.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
NeverMore21
post Dec 30 2006, 12:25 PM
Post #11





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



Ima tu kodova sa raznih site-ova, ali vecina je obradjena za Delphi 7+ biggrin.gif

Imah na
Forumu pomoc wezanu za swe...

Adrese? Hm, pa ima ih mnogo (pored dole navedene):

www.greatis.com/delphicb/tips/lib/tips.html
www.inner-smile.com/delphit.phtml
www.planet-source-code.com
www.delphi32.com
www.chami.com/tips/delphi
www.feedback.nildram.co.uk/richardebbs/delphi/delphitipntrik.htm
www.winsite.com
www.chmaas.handshake.de/delphi/tipsmain.htm
www.programmingtutorials.com/delphi.aspx
www.torry.net

itd.

Na owoj poslednjoj imash i weliki broj komponenti (i freeware i share) koje su mnoooogo bolje od standardnih koje dobijesh uz delphijew VCL paket biggrin.gif!


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Puzzler
post Dec 31 2006, 01:22 PM
Post #12





Group: Članovi
Joined: 2-July 06
Member No.: 74
Status: Van MGa
Škola/Razred: MG/IIb (proud of it)



nevermore je dokaz da je Ib odeljenje bolje nego što svi misle...
Svi sa prve godine, čak i Aovci nas potcenjuju...

In your faces! XD.gif


--------------------
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
NeverMore21
post Dec 31 2006, 01:38 PM
Post #13





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



Dobro, to je tachno, ali to nije tema owog topica... biggrin.gif! U swakom slucaju ima li neko
pitanje wezano za dosadasnje kodowe? Postoji tu jedna greska kod uprawljanja monitorom, jer navedeni kod radi samo pri odredjenoj konfiguraciji. Medjutim, umesto parametra -1 treba stawiti 0 ako wetj sa njim ne radi... Pozzz


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
^_NiN0_^
post Dec 31 2006, 02:13 PM
Post #14


Moderator
Group Icon

Group: Moderatori
Joined: 29-January 06
Member No.: 4
Status: Učenik MGa



Jel to kucamo u Delphi , i pokrenemo ?


--------------------
Yo!hambin,
Yo!hambina, Yo!hambin
Yo-yo, yo-yo, yo
Yo!hambin,
Yo!hambina, Yo!hambiiina
(Mala matura deca kokaina®
Velika matura deca Yo!hambina)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
NeverMore21
post Dec 31 2006, 02:15 PM
Post #15





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



Da u delphi-u! Ovde su ti dati kodovi kao funkcije i procedure - znaci prekopirash ceo kod u aplikaciju i samo ga pozovesh na neki dogadjaj, ok? cheers.gif


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
NeverMore21
post Dec 31 2006, 02:30 PM
Post #16





Group: Članovi
Joined: 21-September 06
From: 21. блок
Member No.: 115
Status: Učenik MGa
Ime i prezime: Bojan Zukic
Škola/Razred: Matematicka gimnazija IVb



OK, ewo stize nowi paket kodowa biggrin.gif

Sledecim kodom mozete blokirati misha i tastaturu (poziwaju se originalne funkcije iz USER32 biblioteke):
CODE

function FuncAvail (_dllname, _funcname: string; var _p: pointer): boolean;
var _lib: tHandle;
begin
   Result := false;
   _p := NIL;
   if LoadLibrary(PChar(_dllname)) = 0 then exit;
   _lib := GetModuleHandle(PChar(_dllname));
   if _lib <> 0 then
    begin
    _p := GetProcAddress(_lib, PChar(_funcname));
    if _p <> NIL then Result := true;
    end;
end;


i onda je pozowete na owaj nacin:
CODE

procedure TForm1.Button1Click(Sender: TObject);
var
   xBlockInput : function(Block: bool):  bool;  stdcall;
begin
  if FuncAvail
   ('USER32.DLL', 'BlockInput', @xBlockInput) then
  begin
   xBlockInput(true);
   Sleep(5000);
   xBlockInput(false);
  end;
end;




Sledeci kod prikazuje desktop (minimizuje swe programe):
CODE

procedure ShowDesktop;
begin
keybd_event( VK_LWIN, MapvirtualKey( VK_LWIN, 0), 0, 0 );
keybd_event( Ord('D'), MapvirtualKey( Ord('D'), 0), 0, 0 );
keybd_event( Ord('D'), MapvirtualKey( Ord('D'), 0), KEYEVENTF_KEYUP, 0 );
keybd_event( VK_LWIN, MapvirtualKey( VK_LWIN, 0), KEYEVENTF_KEYUP, 0 );
end;


Owom funkcijom citate HomePage iz Registry-a:
CODE

uses
Registry;


function GetIEStartPage: string;
var
 Reg: TRegistry;
begin
 Reg := TRegistry.Create;
 try
   Reg.RootKey := HKEY_CURRENT_USER;
   Reg.OpenKey('Software\Microsoft\Internet Explorer\Main', False);
   try
     Result := Reg.ReadString('Start Page');
   except
     Result := '';
   end;
   Reg.CloseKey;
 finally
   Reg.Free;
 end;
end;


I na kraju ewo koda koji menja pozadinu desktopa (ne radi na swim konfiguracijama):
CODE

procedure MenjajPozadinu(putanja: string);
begin
if fileexists(putanja) then
begin

 if  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Pointer(putanja),
   SPIF_SENDWININICHANGE) then    ShowMessage('Wallpaper uspesno promenjen!') else
   ShowMessage('Promena wallpaper-a nije uspela!');       end else
   ShowMessage('Putanja do datoteke nije pronadjena!');
end;



Eto, pa ako ima pitanja postujte biggrin.gif! Nema shta, ipak je owaj API mocna stwar cheers.gif


--------------------
user posted image
user posted image
user posted image
user posted image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicTopic OptionsStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members: