一个设置任意窗口透明度的命令行Delphi程序

  必须是在Windows2000以下的系统才支持SetLayeredWindowAttributes这个API,原理就是先找到窗口句柄,然后设置窗口属性
  program opacity;
  {$APPTYPE CONSOLE}
  uses
   SysUtils,
   Windows;
  var
  handle,AStyle:integer;
  begin
   try
   if ParamCount<2 then
   begin
   Writeln('parameter must');
   exit;
   end;
   handle:=findwindow(nil,pchar(ParamStr(1)));//目前是找窗口的Text,也可以是找ClassName
   AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
   SetWindowLong(Handle, GWL_EXSTYLE, AStyle or WS_EX_LAYERED);
   if SetLayeredWindowAttributes(Handle, 0, strtoint(ParamStr(2)),LWA_ALPHA) then
   Writeln(ParamStr(1)+' update successed to '+ParamStr(2))
   else
   Writeln('Opacity update failed');
   except
   Writeln('parameter error');
   end;
  end.
  http://blog.csdn.net/redbirdli/archive/2007/02/15/1510602.aspx