复制代码
- importcom.ms.dll.*;
- importcom.ms.win32.*;
- classEnumWindowsProcextendsCallback{
- publicbooleancallback(inthwnd,intlparam){
- StringBuffertext=newStringBuffer(50);
- User32.GetWindowText(
- hwnd,text,text.capacity()+1);
- if(text.length()!=0)
- System.out.println(text);
- returntrue;//tocontinueenumeration.
- }
- }
- publicclassShowCallback{
- publicstaticvoidmain(Stringargs[])
- throwsInterruptedException{
- booleanok=User32.EnumWindows(
- newEnumWindowsProc(),0);
- if(!ok)
- System.err.println("EnumWindowsfailed.");
- Thread.currentThread().sleep(3000);
- }
- }
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |