请帮助翻译(50分)

Q

qinmiao

Unregistered / Unconfirmed
GUEST, unregistred user!

HOWTO: Force a Screen Saver to Close Once Started in Windows NT
--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Win32 Software Development Kit (SDK), used with:
Microsoft Windows NT Server versions 3.1, 3.5, 3.51, 4.0
Microsoft Windows NT Workstation versions 3.1, 3.5, 3.51, 4.0
The Microsoft Windows 2000 operating system
--------------------------------------------------------------------------------

SUMMARY
Sometimes applications need to terminate a screen saver that is already running. In Windows 3.1 or Windows 95, a screen saver could be terminated easily by posting a WM_CLOSE message to the currently active screen saver window as in this example:
PostMessage (GetActiveWindow(), WM_CLOSE, 0, 0L);
Windows NT, however, introduces the concept of separate desktops, so that applications can run on one, and screen savers can run on another. This makes screen saver termination under Windows NT and Windows 2000 a bit more difficult.

MORE INFORMATION
Obtaining a handle to the currently active screen saver window under Windows NT or Windows 2000 is not as straightforward as it is in Windows 3.1 and Windows 95. Calling GetForegroundWindow() returns NULL because the screen saver is running on a different desktop than the calling application. Similarly, calling FindWindow ("WindowsScreenSaverClass", NULL) to determine if the screen saver is currently activedo
es not work either.
Todo
this, get a handle to the screen saver's desktop, enumerate that desktop's windows, and then
post a WM_CLOSE to the screen saver window.
The following code demonstrates how todo
this. Note that if a screen saver password is set, the following code brings up the password dialog box, prompts the user for a password, and then
actually terminates the screen saver application.

BOOL CALLBACK KillScreenSaverFunc(HWND hwnd, LPARAM lParam)
{
if(IsWindowVisible(hwnd))
PostMessage(hwnd, WM_CLOSE, 0, 0);
return TRUE;
}
HDESK hdesk;
hdesk = OpenDesktop(TEXT("Screen-saver"),
0,
FALSE,
DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);
if (hdesk)
{
EnumDesktopWindows(hdesk, KillScreenSaverFunc, 0);
CloseDesktop(hdesk);
}
Note that terminating a screen saver that is already running as demonstrated above is totally separate from disabling the screen saver altogether, so that no screen saver starts after the designated time period expires. This can bedo
ne easily using:
SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,
FALSE,
0,
SPIF_SENDWININICHANGE
);
This method works well for terminating the currently running screen saver. However, one problem that you might encounter is that the system will not restart the screen saver unless the user moves the mouse or presses a key. If you need the screen saver to start up again, you'll need to reinitialize the time-out period.do
this by:
Calling SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_SENDWININICHANGE).
-or-

Using SetCursorPos() to simulate user input.

Both of these methods will cause the system to restart the time-out counter for the screen saver.
Additional query words: deactivate disable stop running turn off screensaver
Keywords : kbcode kbOSWinNT kbOSWinNT310 kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbScreenSaver kbSDKWin32 kbGrpUser
Issue type : kbhowto
Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT351search kbWinNT350search kbWinNT400search kbWinNTW350 kbWinNTW350search kbWinNTW351search kbWinNTW351 kbWinNTW310 kbWinNTSsearch kbWinNTS400search kbWinNTS400 kbWinNTS351 kbWinNTS350 kbWinNTS310 kbWinNTS351search kbWinNTS350search kbWinNTS310search kbOSWinNT kbOSWinSearch kbWinNT310Search kbWinNTW310Search

 
F

flyingsky

Unregistered / Unconfirmed
GUEST, unregistred user!
中文翻译如下:
如何在WINDOWS NT下关闭已启动的屏幕保护程序?
该信息适用于在微软WINDOWS NT SERVER 3.1版, 3.5版, 3.51版, 4.0版,WINDOWS NT WORKSTATION
3.1版, 3.5版, 3.51版, 4.0版,WINDOWS2000操作系统下的32位软件开发包(SDK).
摘要:
应用程序有时需要关闭一个正在运行的屏幕保护程序.在WINDOWS 3.1或WINDOWS95中,关闭屏幕保护
程序可以通过向屏幕保护程序窗口发出WM_CLOSE消息来完成,举例如下:
PostMessage (GetActiveWindow(), WM_CLOSE, 0, 0L);
但是,WINDOWS NT中引入了隔离桌面的概念,因此应用程序在一个桌面上运行,而屏幕保护程序在另
一个桌面上运行.这使得在WINDOWS NT和WINDOWS2000下终止屏幕保护程序有一点困难.
更多信息:
在WINDOWS NT和WINDOWS2000中获得当前屏幕保护程序窗口的句柄不象在WINDOWS 3.1和WINDOWS95
下那么直接,调用GetForegroundWindow()函数会返回NULL,因为屏幕保护程序和应用程序运行在不同的
桌面上.类似的,调用FindWindow ("WindowsScreenSaverClass", NULL)函数判断屏幕保护程序是否处于
激活状态同样不能奏效.
怎样找到屏幕保护程序桌面的句柄,然后发送WM_CLOSE消息来关掉屏幕保护程序呢?
下面的代码说明了如何做到这一点.注意:如果屏幕保护程序设置了密码,以下代码会调起一个对话框,
提示用户输入密码,随后终止屏幕保护程序的运行.
BOOL CALLBACK KillScreenSaverFunc(HWND hwnd, LPARAM lParam)
{
if(IsWindowVisible(hwnd))
PostMessage(hwnd, WM_CLOSE, 0, 0);
return TRUE;
}
HDESK hdesk;
hdesk = OpenDesktop(TEXT("Screen-saver"),
0,
FALSE,
DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);
if (hdesk)
{
EnumDesktopWindows(hdesk, KillScreenSaverFunc, 0);
CloseDesktop(hdesk);
}
注意:按照上述方法终止正在运行的屏幕保护程序完全不同于禁止屏幕保护程序那样过了设定的
时间屏幕保护程序不会再出现.为了达到此目的,可以通过以下方法实现:
SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,
FALSE,
0,
SPIF_SENDWININICHANGE
);
这个方法可以很好的完成终止屏幕保护程序的任务.但是你可能面临的问题是:如果用户不移动
鼠标或敲击键盘屏幕保护程序再也不会启动.如果你需要重新启动屏幕保护程序,你需要重新设定等
待时间.可以这样做:
调用SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_SENDWININICHANGE)

用函数SetCursorPos()提示用户输入.
这两种方法都会使系统重新启动屏幕保护程序的定时器.
附加的查询单词:deactivate disable stop running turn off screensaver
关键词:kbcode kbOSWinNT kbOSWinNT310 kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000
kbScreenSaver kbSDKWin32 kbGrpUser
说明类型:kbhowto
技术:kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT351search
kbWinNT350search kbWinNT400search kbWinNTW350 kbWinNTW350search kbWinNTW351search
kbWinNTW351 kbWinNTW310 kbWinNTSsearch kbWinNTS400search kbWinNTS400 kbWinNTS351
kbWinNTS350 kbWinNTS310 kbWinNTS351search kbWinNTS350search kbWinNTS310search
kbOSWinNT kbOSWinSearch kbWinNT310Search kbWinNTW310Search

 
H

happydelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
flyingsky的翻译好厉害,如何才能达到这样的水平呢?
 
C

CrazyMan

Unregistered / Unconfirmed
GUEST, unregistred user!
flyingsky译得真是很好。但我觉得Note that terminating a screen saver that
is already running as demonstrated above is totally separate from
disabling the screen saver altogether,
so that no screen saver starts after the designated time period expires.
这句话是不是应这样理解:
另注:按照上述那样终止正在运行的屏幕保护程序的方法是完全不同于禁止屏幕保护程序的,
因此过了设定的时间屏幕保护程序是不会再出现的.
 
X

xuxiheng

Unregistered / Unconfirmed
GUEST, unregistred user!
Crazyman :
  你的翻译语法上没错,但是意义却完全相反了,仔细看了看happydelphi翻译的那一句,
其它他的意思也挺不错的,只不过在一个句子里,看起来有点...
原意是应该是:
   禁止屏幕保护程序后,过了设定的时间,屏保不会再出现。
   而此程序是过了设定的时间后(只要你在此期间不动键盘,鼠标),屏保还是会出现,
  只不过是暂时性的。
是不是这样翻译比较好一点:
/////////////////////
另注:按照上述范例终止正在运行的屏幕保护程序的方法完全不同于禁止屏幕保护程序
那样,因为后者过了设定的时间后屏幕保护程序是不会再出现的。
////// (只不过把flyingsky的句子多加了几外字,便于理解)
 
 
C

CrazyMan

Unregistered / Unconfirmed
GUEST, unregistred user!
同意xuxiheng的说法
另:
flyingsky对这一句我觉得译得相当好
Todo
this, get a handle to the screen saver's desktop,
enumerate that desktop's windows, and then
post a WM_CLOSE
to the screen saver window.
怎样找到屏幕保护程序桌面的句柄,然后发送WM_CLOSE消息来关掉屏幕保护程序呢?
 
W

welkin2000

Unregistered / Unconfirmed
GUEST, unregistred user!
Crazyman所指译得相当好的一句完全搞错了句子的逻辑结构。而且意思也完全错了。各位再好好
看看原文吧。
 
J

jereen

Unregistered / Unconfirmed
GUEST, unregistred user!
这是我的译文,请多指教:
HOWTO:在Windows NT上终止已启动的屏幕保护程序
本文内容适用于:
微软WIN32软件开发平台,包括:
微软Windows NT服务器版本3.1,3.5,3.51,4.0
微软Windows NT工作站版本3.1,3.5,3.51,4.0
微软Windows 2000操作系统
摘要
应用程序在某些时候需要终止一个已启动的屏幕保护程序。在Windows 3.1 或 Windows 95中,传递一个 “WM_CLOSE”的消息给正在运行的屏幕保护窗口就能轻而易举的结束屏保,
如下所示:
PostMessage (GetActiveWindow(), WM_CLOSE, 0, 0L);
然而,Windows NT引入了分离桌面的概念,应用程序和屏幕保护程序能分别在两个桌面上运行。 这使得在Windows NT 或 Windows 2000下关闭屏保要稍难一些 。
更多内容
在Windows NT 或 Windows 2000下,要得到正在运行的屏保窗口的句柄不象在Windows 3.1 和 Windows 95下那样简单。在应用程序中调用GetForegroundWindow() 将返回空值,
因为屏保和应用程序运行在不同的桌面上。同样,调用FindWindow ("WindowsScreenSaverClass", NULL) 来判断屏保是否正在运行也不起作用。
只有先取得屏保程序所在桌面的句柄,列举该桌面上的窗口,之后再传递“WM_CLOSE”的消息给屏保窗口,这样才能关闭屏保。
下面的代码演示了如何做到这一点。需要指出的是如果设置了屏保口令,下面的代码执行时将调出要求输入口令的对话框,提示用户输入口令,这样一来实际上就终止了屏保。
BOOL CALLBACK KillScreenSaverFunc(HWND hwnd, LPARAM lParam)
{
if(IsWindowVisible(hwnd))
PostMessage(hwnd, WM_CLOSE, 0, 0);
return TRUE;
}
HDESK hdesk;
hdesk = OpenDesktop(TEXT("Screen-saver"),
0,
FALSE,
DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);
if (hdesk)
{
EnumDesktopWindows(hdesk, KillScreenSaverFunc, 0);
CloseDesktop(hdesk);
}
注意,象上面所说的终止一个正在运行的屏保和完全禁止屏保的执行是不同的,在那种情况下,即使过了指定的等待时间屏保也不会再度运行了。
用下面的方法是很容易做到这一点的:
SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,
FALSE,
0,
SPIF_SENDWININICHANGE
);
这一方法也能成功的关闭正在运行的屏保。不过,你将遇到一个问题,那就是系统将不再启动屏幕保护程序除非用户移动鼠标或按下键盘。
如果你需要再度启动屏保,就必须重新初始化屏保的等待时间。要做到这一点你可以:
调用 SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_SENDWININICHANGE).
或者
用SetCursorPos()来模拟用户输入。
这两种方法都将促使系统重新启动屏保等待时间计数器。
附加查询词:解除 禁止 停止 正在运行的 关闭 屏保
关键字:kbcode kbOSWinNT kbOSWinNT310 kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbScreenSaver kbSDKWin32 kbGrpUser
发行种类 : kbhowto
技术 : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT351search kbWinNT350search kbWinNT400search kbWinNTW350 kbWinNTW350search kbWinNTW351search kbWinNTW351 kbWinNTW310 kbWinNTSsearch kbWinNTS400search kbWinNTS400 kbWinNTS351 kbWinNTS350 kbWinNTS310 kbWinNTS351search kbWinNTS350search kbWinNTS310search kbOSWinNT kbOSWinSearch kbWinNT310Search kbWinNTW310Search

 
W

wjiachun

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 

Similar threads

A
回复
0
查看
851
Andreas Hausladen
A
A
回复
0
查看
732
Andreas Hausladen
A
I
回复
0
查看
577
import
I
顶部