如何在 DELPHI 3 C/S 版中使用Windows API调用屏幕保护程序???急用,多谢!(100分)

  • 主题发起人 XiuXiu(OKI)
  • 开始时间
X

XiuXiu(OKI)

Unregistered / Unconfirmed
GUEST, unregistred user!
如何在 DELPHI 3 C/S 版中使用Windows API调用屏幕保护程序???急用,多谢!
 
Winexec('c:/windows/system/ScreenSaverName.scr',SW_SHOW)
 
不好意思,忘了一个参数:<br>Winexec('c:/windows/system/ScreenSaverName.scr /S',SW_SHOW) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^^
 
好象ShellExecute也行 :)
 
ShellExecute( &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; hwmd, &nbsp; &nbsp; &nbsp;//父窗口句柄<br>&nbsp; &nbsp; &nbsp; LPCSTR lpszOp;//要执行操作窜的地址 可以为open ,print默认为open<br>&nbsp; &nbsp; &nbsp; LPCSTR lpszFile;//文件名窜的地址 &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; LPCSTR lpszParams;//执行文件串的地址<br>&nbsp; &nbsp; &nbsp; LPCSTR lpszDir;//默认目录串的地址 &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; int fsShowCmd;//打开时文件是否显示 方式 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br>如果指定文件类型没有联系,和该文件类型中没有与操作的联系,返回31.
 
当然都可以,还有CreateProcess,ShellExecute,ShellExecuteEx等等,<br>我不过给了一个最简单的 :)
 
Let ne sgare sine points, :)<br>You can find the default screen saver from registry:<br>那么请您访问HKEY_CURRENT_USER/Control Panel/Desktop/SCRNSAVE.EXE所读出的文件名就是当前的屏幕保护, 使用<br>ShellExecute执行之
 
好象找不到,至少我的机器不幸!
 
procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; perform(WM_SYSCOMMAND,SC_SCREENSAVE ,0);<br>end;<br><br>All is ok!
 
use followings:<br>winexec('Qstart.exe',sw_Show); <br>其中Qstart.exe在c:/windows下
 
To Micheal_Qu:<br><br>Hi there, wellcome aboard. What is this Qstart.exe thing? Is it a<br>screen saver? Why cann't I find it in my machine.
 
各位哦,启动屏幕保护程序是用另外的WIN API 根本不是SHELL之类的东东,还有QStart是你装了其他屏幕保护后的附带产品(譬如从www.themeking.com来的)<br>正确用法<br><br>SendMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_SCREENSCAVE,0)
 
dsp的perform办法显然对调用当前ScreenSaver最好,<br>但是Execute的办法可以实现调用任何Scr,这一点是优势。
 
哈哈!<br>&nbsp; &nbsp;我来对这个问题作一个了断:<br>请参看以下示例:<br>var &nbsp;b : bool;<br>&nbsp;begin &nbsp;<br>&nbsp; result := false;<br>&nbsp; if SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,@b,0) &lt;&gt; true <br>&nbsp; &nbsp;then exit;//查询当前系统的ScreenSaver是否可用。<br>&nbsp; if not b then exit;//不可用则退出<br>&nbsp; PostMessage(GetDesktopWindow, WM_SYSCOMMAND, SC_SCREENSAVE, 0);<br>&nbsp; &nbsp;//或SendMessage(GetDesktopWindow,WM_SYSCOMMAND,SC_SCREENSCAVE,0);<br>&nbsp; &nbsp;//或perform(WM_SYSCOMMAND,SC_SCREENSAVE ,0);<br>&nbsp; result := true;<br>end;
 
Screen Saver是个其实也是EXE文件所以,象执行其他exe一样执行就可以了。<br><br>哦,差点说错了,要运行他是加/s参数,不加参数是打开SSaver配置界面。
 
sorry , i made a mistake .that should be<br>winexec('*****.** &nbsp;/s',sw_Show); <br>其中*****.** 代屏保文件名
 
sorry , i made a mistake .that should be<br>winexec('*****.** &nbsp;/s',sw_Show); <br>其中*****.** 代屏保文件名
 
多人接受答案了。
 
顶部