///Copy的
从Win98开始,微软更改了系统代码,一般的SetForegroundWindow只能将
状态栏中应用按钮闪烁,并没有将应用调到最前面。请使用下列函数:
function ForceForegroundWindow(hwnd: THandle): boolean;
const
SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
var
timeout: DWORD;
begin
if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion
> 4)) or
((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and
(Win32MinorVersion > 0)))) then begin
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout,
0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
TObject(0), SPIF_SENDCHANGE);
Result := SetForegroundWindow(hWnd);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
TObject(timeout), SPIF_SENDCHANGE);
end
else
Result := SetForegroundWindow(hWnd);
end; { ForceForegroundWindow }
***********************
发现一个2000下面的方法,试一下
function AllowSetForegroundWindow( dwProcessId
WORD): BOOL; stdcall;
implementation
function AllowSetForegroundWindow; external 'user32.dll' name 'AllowSetForegroundWindow';