2007年9月14日		  
	#
		
			
			
			     摘要: 重构前的代码,使用字符串处理状态
package org.zsk.refact;
public class SystemPermission {
    private String state;
    private boolean&...  
阅读全文
			
			
		 
	
	
		
	2007年9月3日		  
	#
		
			
			
			 unit Unit1;
unit Unit1;

 interface
interface

 uses
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;
  Dialogs, StdCtrls;

 type
type
 TEvent = procedure () of object;
  TEvent = procedure () of object;
 TProc = procedure();
  TProc = procedure();

 TForm1 = class(TForm)
  TForm1 = class(TForm)
 btn1: TButton;
    btn1: TButton;
 procedure btn1Click(Sender: TObject);
    procedure btn1Click(Sender: TObject);
 private
  private

 
     { Private declarations }
{ Private declarations }
 public
  public

 
     { Public declarations }
{ Public declarations }
 end;
  end;

 var
var
 Form1: TForm1;
  Form1: TForm1;

 implementation
implementation



 {$R *.dfm}
{$R *.dfm}

 procedure TForm1.btn1Click(Sender: TObject);
procedure TForm1.btn1Click(Sender: TObject);
 begin
begin
 showmessage('方法指针的长度是:'+Inttostr(SizeOf(TEvent)));
  showmessage('方法指针的长度是:'+Inttostr(SizeOf(TEvent)));
 showmessage('函数指针的长度是:'+Inttostr(SizeOf(TProc)));
  showmessage('函数指针的长度是:'+Inttostr(SizeOf(TProc)));
 end;
end;

 //函数指针是指向函数的32位指针,占4个字节。
//函数指针是指向函数的32位指针,占4个字节。
 //过程的指针结构如下
//过程的指针结构如下
 //  PProc = ^TProc;//过程指针
//  PProc = ^TProc;//过程指针
 // TProc = record
// TProc = record
 //  Code: Pointer;//指向过程的代码
//  Code: Pointer;//指向过程的代码
 // end;
// end;
 //方法指针是指向一个结构。方法的指针结构如下
//方法指针是指向一个结构。方法的指针结构如下
 //  PMethod = ^TMethod;//方法指针
//  PMethod = ^TMethod;//方法指针
 // TMethod = record
// TMethod = record
 //  Code: Pointer;//指向方法的代码
//  Code: Pointer;//指向方法的代码
 //    Data: Pointer;//指向对象的数据
//    Data: Pointer;//指向对象的数据
 // end;
// end;



 end.
end. 
	
		
			
			
			 SetForegroundWindow(HApp);
  SetForegroundWindow(HApp);
 keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
  keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
 keybd_event(ORD('B'), MapVirtualKey(Byte('t'), 0), 0, 0);
  keybd_event(ORD('B'), MapVirtualKey(Byte('t'), 0), 0, 0);
 keybd_event(Byte('B'), MapVirtualKey(Byte('t'), 0), KEYEVENTF_KEYUP, 0);
  keybd_event(Byte('B'), MapVirtualKey(Byte('t'), 0), KEYEVENTF_KEYUP, 0);
 keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
  keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);


 //Ctrl: VK_CONTROL
//Ctrl: VK_CONTROL
 //SHIFT:VK_SHIFT
//SHIFT:VK_SHIFT
 //TAB:  VK_TAB
//TAB:  VK_TAB
 //ALT:  VK_MENU
//ALT:  VK_MENU
 //'A':  byte('A')
//'A':  byte('A')
功能说明,
通过目标程序的句柄将该程序激活;
模拟鼠标按下
模拟鼠标抬起
 
			
			
		
 
	
		
			
			
			PostMessage 只是把消息放入队列,不管其他程序是否处理都返回,然后继续执行 ;
而 SendMessage 必须等待其他程序处理消息后才返回,继续执行。 
PostMessage 的返回值表示 PostMessage 函数执行是否正确 ;
而 SendMessage 的返回值表示其他程序处理消息后的返回值。 
使用这两个发送消息函数的最重要的是要看你的程序是否要对消息的滞后性关注否 ,PostMessage 会造成消息的滞后性 , 而 SendMessage 则不会 , 但如果 SendMessage 消息处理失败 , 则会造成程序停止 ! 
为了让大家能清楚的看到他们的效果,可以用下面的代码进行测试:
 unit Unit1;
unit Unit1;

 interface
interface

 uses
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;
  Dialogs, StdCtrls;

 type
type
 TForm1 = class(TForm)
  TForm1 = class(TForm)
 mmo1: TMemo;
    mmo1: TMemo;
 btn2: TButton;
    btn2: TButton;
 btn3: TButton;
    btn3: TButton;
 procedure btn2Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
 procedure btn3Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
 private
  private

 
     { Private declarations }
{ Private declarations }
 procedure testPostMessage;
    procedure testPostMessage;
 procedure testSendMessage;
    procedure testSendMessage;
 public
  public

 
     { Public declarations }
{ Public declarations }
 end;
  end;

 var
var
 Form1: TForm1;
  Form1: TForm1;

 implementation
implementation

 uses uFile;
uses uFile;



 {$R *.dfm}
{$R *.dfm}
 var
var
 f: TFile;
  f: TFile;

 procedure TForm1.btn2Click(Sender: TObject);
procedure TForm1.btn2Click(Sender: TObject);
 var
var
 i: Integer;
  i: Integer;
 begin
begin
 testPostMessage;
  testPostMessage;
 for i := 0 to 5000 do
  for i := 0 to 5000 do
 begin
  begin
 mmo1.Lines.Add(IntToStr(i)+'======');
    mmo1.Lines.Add(IntToStr(i)+'======');
 end;
  end;
 end;
end;

 procedure TForm1.btn3Click(Sender: TObject);
procedure TForm1.btn3Click(Sender: TObject);
 var
var
 i: Integer;
  i: Integer;
 begin
begin
 testSendMessage;
  testSendMessage;
 for i := 0 to 5000 do
  for i := 0 to 5000 do
 begin
  begin
 mmo1.Lines.Add(IntToStr(i)+'======');
    mmo1.Lines.Add(IntToStr(i)+'======');
 end;
  end;
 end;
end;

 procedure TForm1.testPostMessage;
procedure TForm1.testPostMessage;
 var
var
 i: Integer;
  i: Integer;
 begin
begin
 PostMessage(f.Handle, WM_TEST, 0, 0);
  PostMessage(f.Handle, WM_TEST, 0, 0);
 for i := 0 to 5000 do
  for i := 0 to 5000 do
 begin
  begin
 mmo1.Lines.Add(IntToStr(i))
    mmo1.Lines.Add(IntToStr(i))
 end;
  end;
 end;
end;

 procedure TForm1.testSendMessage;
procedure TForm1.testSendMessage;
 var
var
 i: Integer;
  i: Integer;
 begin
begin
 SendMessage(f.Handle, WM_TEST, 0, 0);
  SendMessage(f.Handle, WM_TEST, 0, 0);
 for i := 0 to 5000 do
  for i := 0 to 5000 do
 begin
  begin
 mmo1.Lines.Add(IntToStr(i))
    mmo1.Lines.Add(IntToStr(i))
 end;
  end;
 end;
end;

 initialization
initialization
 if f = nil then
  if f = nil then
 f := TFile.Create;
    f := TFile.Create;

 finalization
finalization
 if f <> nil then
  if f <> nil then
 FreeAndNil(f);;
    FreeAndNil(f);;

 end.
end.

 unit uFile;
unit uFile;

 interface
interface

 uses
uses
 Classes, Windows, Forms, Messages;
  Classes, Windows, Forms, Messages;

 const
const
 WM_TEST = WM_USER + 1;
  WM_TEST = WM_USER + 1;

 type
type
 TFile = class
  TFile = class
 private
  private
 FHandle: HWND;
    FHandle: HWND;
 protected
  protected
 procedure WndProc(var Msg: TMessage);
    procedure WndProc(var Msg: TMessage);
 public
  public
 procedure AfterConstruction; override;
    procedure AfterConstruction; override;
 procedure BeforeDestruction; override;
    procedure BeforeDestruction; override;
 property Handle: HWND  read FHandle;
    property Handle: HWND  read FHandle;
 end;
  end;

 implementation
implementation



 { TFile }
{ TFile }

 procedure TFile.AfterConstruction;
procedure TFile.AfterConstruction;
 begin
begin
 inherited;
  inherited;
 FHandle := AllocateHWnd(WndProc);
  FHandle := AllocateHWnd(WndProc);
 end;
end;

 procedure TFile.BeforeDestruction;
procedure TFile.BeforeDestruction;
 begin
begin
 inherited;
  inherited;
 DeallocateHWnd(FHandle);
  DeallocateHWnd(FHandle);
 end;
end;

 procedure TFile.WndProc(var Msg: TMessage);
procedure TFile.WndProc(var Msg: TMessage);
 begin
begin
 if msg.Msg = WM_TEST then
  if msg.Msg = WM_TEST then
 begin
  begin
 //消息处理内容
    //消息处理内容
 Application.MessageBox('WM_TEST', 'WM_TEST', 0);
    Application.MessageBox('WM_TEST', 'WM_TEST', 0);
 end;
  end;  
 windows.DefWindowProc(FHandle, Msg.Msg, Msg.wParam, Msg.lParam);
  windows.DefWindowProc(FHandle, Msg.Msg, Msg.wParam, Msg.lParam);
 end;
end;

 end.
end.

 
	
		
	
	
		
	2007年9月1日		  
	#
		
			
			
			   直接在VC6下就能编译,记得不能Build All,只要在FileView选项卡下分别Build vncviewer files和winvnc files就可以。
   特别感谢老张给的源码和帮助编译。
			
			
		
 
	
		
			
			
			常用设置
1、显示行号    Window->Preferences->General->Editors->Text Editor 选择Show line numbers
2、设置UTF-8   Window->Preferences->General->Workspace 中Text file encoding 选择other并选UTF-8
快捷键
1、运行程序  Alt+Shift+X   按J     run as javaApplication (按下Alt+Shift+X 后Eclipase右下角有提示)
2、排版    选中多行文本
            Tab    后缩
            Shift + Tab  前进
			
			
		 
	
		
			
			
			实现思路分析:
1、找到目标程序的句柄,可以通过窗口的caption属性获取,使用
 FindWindow(nil, 'app caption');
FindWindow(nil, 'app caption');
2、找到你要控制的组件,如Button,使用
 FindWindowEx(ParentHandle, 0, nil, 'btn caption');
FindWindowEx(ParentHandle, 0, nil, 'btn caption');
3、发送Windows消息控制目标程序
 SendMessage( HEdt, BM_CLICK, 0, 0 );
SendMessage( HEdt, BM_CLICK, 0, 0 );
下面是实现该功能的Delphi代码:
 unit Unit1;
unit Unit1;


 Interface usesinterface
Interface usesinterface

 uses
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;
  Dialogs, StdCtrls;

 type
type

 TForm1 = Class (class(TForm)
  TForm1 = Class (class(TForm)
 btn1: TButton;
    btn1: TButton;
 mmo1: TMemo;
    mmo1: TMemo;
 edt1: TEdit;
    edt1: TEdit;
 edt2: TEdit;
    edt2: TEdit;
 btn3: TButton;
    btn3: TButton;
 lbl1: TLabel;
    lbl1: TLabel;
 lbl2: TLabel;
    lbl2: TLabel;
 btn4: TButton;
    btn4: TButton;
 procedure btn1Click(Sender: TObject);
    procedure btn1Click(Sender: TObject);
 procedure btn3Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
 procedure btn4Click(Sender: TObject);
    procedure btn4Click(Sender: TObject);
 private
  private
 { Private declarations }
    { Private declarations }
 public
  public
 { Public declarations }
    { Public declarations }
 end;
  end;

 var
var
 Form1: TForm1;
  Form1: TForm1;

 implementation
implementation

 uses
uses
 ShellAPI;
  ShellAPI;

 {$R *.dfm}
{$R *.dfm}
 var
var
 HApp,
  HApp,
 HEdt : THandle;
  HEdt : THandle;

 procedure TForm1.btn1Click(Sender: TObject);
procedure TForm1.btn1Click(Sender: TObject);
 begin
begin
 HApp := FindWindow(nil, PAnsiChar(edt1.text));
  HApp := FindWindow(nil, PAnsiChar(edt1.text));
 mmo1.Lines.Add(IntToStr(HApp));
  mmo1.Lines.Add(IntToStr(HApp));

 HEdt := FindWindowEx(HApp, 0, nil, PAnsiChar(edt2.text));
  HEdt := FindWindowEx(HApp, 0, nil, PAnsiChar(edt2.text));
 mmo1.Lines.Add(IntToStr(HEdt));
  mmo1.Lines.Add(IntToStr(HEdt));
 SendMessage( HEdt, BM_CLICK, 0, 0 );
  SendMessage( HEdt, BM_CLICK, 0, 0 );
 end;
end;

 procedure TForm1.btn3Click(Sender: TObject);
procedure TForm1.btn3Click(Sender: TObject);
 begin
begin
 ShellExecute(handle, 'open', 'otherapp.exe',nil,nil, SW_SHOWNORMAL{SW_SHOWMAXIMIZED});
  ShellExecute(handle, 'open', 'otherapp.exe',nil,nil, SW_SHOWNORMAL{SW_SHOWMAXIMIZED});
 end;
end;

 procedure TForm1.btn4Click(Sender: TObject);
procedure TForm1.btn4Click(Sender: TObject);
 begin
begin
 SendMessage( HApp, WM_CLOSE, 0, 0 );
  SendMessage( HApp, WM_CLOSE, 0, 0 );
 end;
end;

 end.
end. 
	
	
		
	2007年8月31日		  
	#
		
			
			
			    随着网站信息量越来越大,有90%的网页内容超过了一屏。这给那些想以图片格式保存页面信息的朋友带来不少的麻烦,例如想保存网页缩略图、交易取证、侵权取证等各种需求。
为此,企风科技特向大家推出一款绿色免费的网页滚动截图软件,让你所见即所得、随心所欲保存您喜欢的页面。
   下载:
    
zhangsk.cn下载
    BlogJava下载
			
			
		
 
	
		
			
			
			 1 package org.zsk.error;
 2 
 3 public class MultiThreadDemo1_1 {
 4 
 5     public MultiThreadDemo1_1() {
 6         // TODO Auto-generated constructor stub
 7         new NewThread("1");       
 8         new NewThread("2");   
 9         new NewThread("3");
10         new NewThread("4");
11 
12         System.out.println("main thread begin!");
13         for (int i=0; i<100; i++){
14             System.out.println("  -->  ");
15            
16         }
17         System.out.println("main thread end;");
18 
19     }
20 
21     /**
22      * @param args
23      */
24     public static void main(String[] args) {
25         // TODO Auto-generated method stub
26         new MultiThreadDemo1_1();
27     }
28    
29     class NewThread implements Runnable {
30         NewThread(String threadName){
31             name = threadName;
32             t = new Thread(this, name);
33             t.start();
34             System.out.println("new thread " + name + "begin");           
35         }
36        
37         public void run(){
38             try{
39                 for (int i=0; i<100; i++){
40                     System.out.println(name);
41                     Thread.sleep(30);
42                 }                   
43             } catch (InterruptedException e) {
44                 System.out.println("thread "+name+"error!");
45             }
46                
47             System.out.println("thread " + name + "end;");
48         }
49        
50         private String name;
51         private Thread t;
52     }
53 
54 }