ÓÃDelphi¿ª·¢ÆÁÄ»±£»¤Ô¤ÀÀ³ÌÐò
ÕûÀí±à¼£ºChina ASP
---- ´ó ¼Ò ¶¼ Öª µÀwindows ÆÁ Ä» ±£ »¤ ³Ì Ðò µÄ ×÷ ÓÃ, ¶ø ÇÒ Ð µÄ ÆÁ Ä» ±£ »¤ ³Ì Ðò Ô½ À´ Ô½ Ư ÁÁ. Èç ¹û ÔÚwin95 µÄ ×À Ãæ ÓÒ ¼ü ²Ë µ¥ Ñ¡ Êô ÐÔ, ¾Í µ¯ ³ö ÏÔ Ê¾ Æ÷ Éè Öà ½ç Ãæ, ÓÐ Ò» ¸ö ±ê Ç© ÊÇ Éè Öà ÆÁ Ä» ±£ »¤ ³Ì Ðò µÄ.
---- ÔÚ ¸Ã Ò³ µÄ » Ãæ ÉÏ, ÓÐ Ò» ¸ö ÏÔ Ê¾ Æ÷ ͼ °¸, Èç ¹û Äã Ñ¡ Ôñwin95 Ëù ´ø µÄ ÆÁ Ä» ±£ »¤ ³Ì Ðò, Õâ ¸ö ÆÁ Ä» ±£ »¤ ³Ì Ðò ¾Í »á ÔÚ Õâ ¸ö С´ ÏÔ Ê¾ Æ÷´ ÉÏ ×Ô ¶¯ ÔË ÐÐ, Äã ¿É ÒÔ Ö± ½Ó ¿´ µ½ ÔË ÐРЧ ¹û. Õâ ¹¦ ÄÜ ´ó ´ó ·½ ±ã ÁË ÆÁ Ä» ±£ »¤ ³Ì Ðò µÄ Ñ¡ Ôñ, Õâ ¾Í ÊÇwin95 ¶Ô ÆÁ Ä» ±£ »¤ ³Ì Ðò µÄ РÔö ½Ó ¿Ú: Ô¤ ÀÀ ¹¦ ÄÜ.
---- Ä¿ ǰ ´ó ¶à Êý ÐÂ ÍÆ ³ö µÄ ÆÁ Ä» ±£ »¤ ³Ì Ðò ¶¼ Ö§ ³Ö Õâ ¸ö ½Ó ¿Ú.
---- ÆÁ Ä» ±£ »¤ ³Ì Ðò ´Ó Ëü µÄ µ® Éú ÄÇ Ê± Æð, ÔÚ Í¬ Ò» ʱ ¿Ì Ö» ÄÜ ÔË ÐÐ Ò» ¸ö, ²» ÄÜ ¶à ¸ö ͬ ʱ ÔË ÐÐ, È» ¶ø Ô¤ ÀÀ ½Ó ¿Ú µÄ ÍÆ ³ö, ʹ ͬ ʱ Ô¤ ÀÀ ¶à ¸ö ÆÁ Ä» ±£ »¤ ³Ì Ðò ³É Ϊ ¿É ÄÜ, ±¾ ÎÄ ½« Ïò ¶Á Õß ½é ÉÜ Èç ºÎ ÓÃDelphi ¿ª ·¢ Õâ Ñù Ò» ¸ö ³Ì Ðò.
---- 1. ÆÁ Ä» ±£ »¤ Ô¤ ÀÀ ½Ó ¿Ú
---- ÆÁ Ä» ±£ »¤ Ô¤ ÀÀ ½Ó ¿Ú µÄ ʹ Óà ºÜ ¼ò µ¥, Õâ ÊÇ Í¨ ¹ý ´« ¸ø ÆÁ Ä» ±£ »¤ ³Ì Ðò µÄ Ãü Áî ÐÐ ²Î Êý À´ ʵ ÏÖ µÄ, ¸Ã Ãü Áî ÐÐ ²Î Êý ¸ñ ʽ Ϊ:
---- screensaver.exe /p #####
---- Æä ÖÐ##### Ϊ Ò» ¸ö ÓРЧ µÄ ´° ¿Ú ¾ä ±ú µÄ10 ½ø ÖÆ ±í ʾ.
---- Õâ ¸ö ´° ¿Ú ÎÒ ÃÇ ¿É ÒÔ ³Æ Ö® Ϊ Ô¤ ÀÀ ´° ¿Ú.
---- ʵ ¼Ê ÉÏ, Ö§ ³Ö Ô¤ ÀÀ ½Ó ¿Ú µÄ ÆÁ Ä» ±£ »¤ ³Ì Ðò ½« ×Ô ¼º µÄ ´° ¿Ú ´´ ½¨ Ϊ Ô¤ ÀÀ ´° ¿Ú µÄ ×Ó ´° ¿Ú À´ ʵ ÏÖ Ô¤ ÀÀ ¹¦ ÄÜ µÄ.
---- 2. » Ãæ ²¼ ¾Ö
---- ÎÒ ÃÇ Õâ ¸ö ³Ì Ðò µÄ ´° ¿Ú ·Ö Ϊ 3 ²¿ ·Ö, Ϊ µ¹´ Æ·´ ×Ö ÐÎ, ÉÏ ×ó ²¿ ·Ö ÁÐ ³ö Ëù ÓÐ ¿É Óà µÄ ÆÁ Ä» ±£ »¤ ³Ì Ðò, ÉÏ ÓÒ ²¿ ·Ö ÁÐ ³ö Ëù ÓÐ Ô¤ ÀÀ µÄ ÆÁ Ä» ±£ »¤ ³Ì Ðò, ÏÂ Ãæ µ± È» ÊÇ Ô¤ ÀÀ ´° ¿Ú ÁË.
---- ÓÃDelphi ʵ ÏÖ Ê±, Ê× ÏÈ ÔÚForm Àï ·Å2 ¸öTPanel ×é ¼þ, Panel1 ¶Ô Æë ·½ ʽ Ϊ ¶¥ ²¿ ¶Ô Æë,Panel2 Ϊ ³Å Âú Óà »§ Çø, ÔÙ ÔÚPanel1 ÖÐ ·Å1 ¸öTFileListBox ×é ¼þ ºÍ Ò» ¸öTListBox ×é ¼þ,FileListBox1 ×ó ¶Ô Æë, ListBox1 ³Å Âú Óà »§ Çø.
---- Õâ Ñù, FileListBox1 Ϊ ÆÁ Ä» ±£ »¤ ÁÐ ±í, ListBox1 Ϊ Ô¤ ÀÀ ÁÐ ±í, Panel2 Ϊ Ô¤ ÀÀ ´° ¿Ú.
---- 3. ÁÐ ³ö ÆÁ Ä» ±£ »¤ ³Ì Ðò.
---- ½«FileListBox1 µÄMask Êô ÐÔ Éè Ϊ´*.scr´, Õâ ÊÇ ÆÁ Ä» ±£ »¤ ³Ì Ðò µÄ À© Õ¹ Ãû.
---- ÔÚFormCreate ·½ ·¨ ÖÐ ½«FileListBox1.directory Éè Ϊwindows ϵ ͳ Ä¿ ¼GetSystemDirectory;
---- 4. Ô¤ ÀÀ ÆÁ Ä» ±£ »¤ ³Ì Ðò.
---- ÔÚFileListBox1DblClick ·½ ·¨ ÖÐ ÔË ÐÐ ¸Ã ÆÁ Ä» ±£ »¤ ³Ì Ðò, ²¢ ½«Panel2 µÄ ´° ¿Ú ¾ä ±ú ´« ¸ø Ëü.
---- WinExec(pchar(FileListBox1.FileName + ´ /p ´ + inttostr(Panel2.handle)), SW_Show);
---- ÔË ÐÐ ³Ì Ðò, Ôõ ô Ñù? COOL!
---- 5. Ôö ¼Ó Ò» Щ ÐÂ ÌØ ÐÔ: Òþ ²Ø/ ÏÔ Ê¾/ ¹Ø ±Õ.
---- Ôö ¼Ó2 ¸ö º¯ Êý: Óà ÓÚ ¸ü ÐÂListBox1.
function EnumProc(
h : HWND ;// handle of child window
l : integer// application-defined value
): boolean;stdcall;
var
buf : array[0..255] of char;
begin
GetWindowText(h, buf, sizeof(buf)- 1);
if iswindowvisible(h) then
Form1.ListBox1.items.add(´ ´ +strpas(buf) + ´ : ´ + inttostr(h))
else
Form1.ListBox1.items.add(´-´ +strpas(buf) + ´ : ´ + inttostr(h));
Result := true;
end;
procedure TForm1.Fresh1;
begin
ListBox1.clear;
enumChildwindows(Panel2.handle,
TFNWndEnumProc(@enumproc), 0);
end;
---- Ôö ¼Ó Ò» ¸ö µ¯ ³ö ²Ë µ¥Popupmenu1, 3 ¸ö ²Ë µ¥ Ïî, ´Show, Hide, Close´, ½«ListBox1.popupmemu Ö¸ ÏòPopupmenu1.
---- Hide µÄ ´¦ Àí º¯ Êý ÊÇ:
procedure TForm1.Hide1Click(Sender: TObject);
var
h : integer;
s : string;
begin
if ListBox1.itemindex = -1 then exit;
s := Listbox1.items[ListBox1.itemindex];
h := strtoint(copy(s, pos(´:´, s) + 1, length(s)));
ShowWindow(h, SW_HIDE);
Fresh1;
end;
Show µÄ ´¦ Àí º¯ Êý ÊÇ:
procedure TForm1.Show1Click(Sender: TObject);
var
h : integer;
s : string;
begin
if ListBox1.itemindex = -1 then exit;
s := Listbox1.items[ListBox1.itemindex];
h := strtoint(copy(s, pos(´:´, s) + 1, length(s)));
ShowWindow(h, SW_SHOW);
Fresh1;
end;
Close µÄ ´¦ Àí º¯ Êý ÊÇ:
procedure TForm1.Close1Click(Sender: TObject);
var
h : integer;
s : string;
begin
if ListBox1.itemindex = -1 then exit;
s := Listbox1.items[ListBox1.itemindex];
h := strtoint(copy(s, pos(´:´, s) + 1, length(s)));
PostMessage(h, WM_QUIT, 0, 0);
Fresh1;
end;
---- ±¾ ³Ì Ðò ÔÚDelphi 3.0 Ï µ÷ ÊÔ Í¨ ¹ý, Ó¦ ¸Ã ÄÜ ÓÃDelphi 1.0 / 2.0 ±à Òë.
---- Íê Õû ³Ì Ðò Èç ÏÂ:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, FileCtrl, ExtCtrls, Menus;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
FileListBox1: TFileListBox;
ListBox1: TListBox;
PopupMenu1: TPopupMenu;
Hide1: TMenuItem;
Show1: TMenuItem;
Close1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FileListBox1DblClick(Sender: TObject);
procedure Hide1Click(Sender: TObject);
procedure Show1Click(Sender: TObject);
procedure Close1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Fresh1;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function EnumProc(
h : HWND ;// handle of child window
l : integer// application-defined value
): boolean;stdcall;
var buf : array[0..255] of char;
begin
GetWindowText(h, buf, sizeof(buf)- 1);
if iswindowvisible(h) then
Form1.ListBox1.items.add(´ ´ +strpas(buf) + ´ : ´ + inttostr(h))
else
Form1.ListBox1.items.add(´-´ +strpas(buf) + ´ : ´ + inttostr(h));
Result := true;
end;
procedure TForm1.Fresh1;
begin
ListBox1.clear;
enumChildwindows(Panel2.handle, TFNWndEnumProc(@enumproc), 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
var buf : array[0..256] of char;
begin
GetSystemDirectory(buf, sizeof(buf) - 1);
FileListBox1.directory := strpas(buf);
ListBox1.popupmenu := Popupmenu1;
end;
procedure TForm1.FileListBox1DblClick(Sender: TObject);
begin
WinExec(pchar(FileListBox1.FileName + ´ /p ´ + inttostr(Panel2.handle)), SW_Show);
Fresh1;
end;
procedure TForm1.Hide1Click(Sender: TObject);
var
h : integer;
s : string;
begin
if ListBox1.itemindex = -1 then exit;
s := Listbox1.items[ListBox1.itemindex];
h := strtoint(copy(s, pos(´:´, s) + 1, length(s)));
ShowWindow(h, SW_HIDE);
Fresh1;
end;
procedure TForm1.Show1Click(Sender: TObject);
var
h : integer;
s : string;
begin
if ListBox1.itemindex = -1 then exit;
s := Listbox1.items[ListBox1.itemindex];
h := strtoint(copy(s, pos(´:´, s) + 1, length(s)));
ShowWindow(h, SW_SHOW);
Fresh1;
end;
procedure TForm1.Close1Click(Sender: TObject);
var
h : integer;
s : string;
begin
if ListBox1.itemindex = -1 then exit;
s := Listbox1.items[ListBox1.itemindex];
h := strtoint(copy(s, pos(´:´, s) + 1, length(s)));
PostMessage(h, WM_QUIT, 0, 0);
Fresh1;
end;
end.
Copyright © ÉϺ£¾ÛÉù¼ÆËã»úϵͳ¹¤³ÌÓÐÏÞÔðÈι«Ë¾ 1999-2000, All Rights Reserved

