CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  VCL组件开发及应用

这段Delphi英文帮助是什么意思?(三天结帖)

楼主chons(不羁之城)2002-07-31 20:42:47 在 Delphi / VCL组件开发及应用 提问

The   following   example   shows   how   to   tell   Windows   to   relaunch   your   application   when   Windows   starts   up   if   it   was   running   when   the   system   shut   down.   When   Windows   starts   up,   it   launches   each   application   listed   in   the   RunOnce   key   and   then   deletes   the   entry   for   that   application.     Therefore,   you   do   not   need   to   remove   the   entry   written   here.  
   
  procedure   TForm1.WMEndSession(var   Message:   TWMEndSession);  
  var  
      Reg:   TRegistry;  
  begin  
      Reg   :=   TRegistry.Create;  
      try  
          Reg.RootKey   :=   HKEY_CURRENT_USER;  
          if   Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunOnce',   True)   then  
        begin  
              Reg.WriteString('MyApp','"'   +   ParamStr(0)   +   '"');  
              Reg.CloseKey;  
          end;  
      finally  
          Reg.Free;  
          inherited;  
      end;  
   
  end;  
   
   
   
  In   order   for   this   method   to   be   called,   it   must   be   declared   in   your   main   form   class   as   follows:  
   
  private  
   
      procedure   WMEndSession(var   Msg:TWMEndSession);   message   WM_ENDSESSION; 问题点数:100、回复次数:15Top

1 楼chons(不羁之城)回复于 2002-07-31 20:43:52 得分 0

这个程序到底是起什么作用?  
  响应什么消息就写东西到注册表里去?  
  Top

2 楼lvloj()回复于 2002-07-31 20:51:39 得分 0

简单的说:  
      这个例子显示了如何让Windows在启动时运行你的程序。  
  procedure   TForm1.WMEndSession(var   Message:   TWMEndSession);  
  var  
      Reg:   TRegistry;  
  begin  
      Reg   :=   TRegistry.Create;  
      try  
          Reg.RootKey   :=   HKEY_CURRENT_USER;  
          if   Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunOnce',   True)   then  
        begin  
              Reg.WriteString('MyApp','"'   +   ParamStr(0)   +   '"');  
              Reg.CloseKey;  
          end;  
      finally  
          Reg.Free;  
          inherited;  
      end;  
   
  end;  
   
  为了能调用这个方法,它必须声明在你主窗体的Class下:^_^  
  private  
   
      procedure   WMEndSession(var   Msg:TWMEndSession);   message   WM_ENDSESSION;{这应该是一个Windows要关闭的消息}  
  Top

3 楼manboo(我从山中来)回复于 2002-07-31 20:58:45 得分 0

如何当你的程序运行时,再RunAtOnce下面加入一个键这样当Windouws关闭后  
  可以重新运行你的程序!Top

4 楼slwqw(四大名捕之追杀令)回复于 2002-07-31 20:59:35 得分 0

看得懂,但翻译还真不知道(高考语文不及格^_^)。  
   
  ------------------------  
   
  当Windows启动的时候,它自动读取注册表的HKLM\...\RunOnce建底下的子键,并运行该子键所对应的程序,然后把该子键删除。  
   
  上面的程序截获消息WM_ENDSESSION,以在Windows关闭时得到通知,当Windows关闭时,程序自动在RunOnce键底下建立一个子键,这样下次Windows启动时就自动启动这个程序,这样一直循环,你的程序永远在Windows启动之前启动。  
   
  -------------------------  
   
  实际上我认为这段代码有问题,应该在RunOnce下面建立子键而不是设置它的值。Top

5 楼slwqw(四大名捕之追杀令)回复于 2002-07-31 21:02:16 得分 0

这个程序在Windows的Explorer.exe启动之前启动,也就是在桌面加载之前启动,而且在没有结束这个程序之前,Explorer.exe不会被启动。Top

6 楼killers100(哈哈)回复于 2002-07-31 21:37:25 得分 0

同意   BCB_FANS(四大名捕之追杀令)   所解释,正是如此。  
   
  另:  
  该键值也可用在程序非正常退出后,重启Windows时你的程序可以自动运行。  
  具体实现方法:  
      (1)、程序启动时在runonce键中写入你的程序。  
    (2)、程序退出时删除该键值。  
  实现原理:  
      因为你的应用程序如非正常退出后,该键值未删除。Windows重新启动后,其会读取该键值,并运行你的程序。然后删除该键值,从而实现只运行一次。Top

7 楼windofsun(太阳风)回复于 2002-07-31 21:39:06 得分 0

这段程序是当你的应用程序正在运行时就被关机,当下次Windows启动时还会打开那个应用程序Top

8 楼fermium(列御寇)回复于 2002-07-31 22:04:55 得分 0

The   following   example   shows   how   to   tell   Windows   to   relaunch   your   application   when   Windows   starts   up   if   it   was   running   when   the   system   shut   down.  
  这段程序是当你的应用程序正在运行时就被关机,当下次Windows启动时还会打开那个应用程序  
    When   Windows   starts   up,   it   launches   each   application   listed   in   the   RunOnce   key   and   then   deletes   the   entry   for   that   application.  
  当Windows启动时它将运行所有在RunOnce键里列出的程序,并删除该程序的入口。  
  Therefore,   you   do   not   need   to   remove   the   entry   written   here.  
  所以,你不用(自己)去掉在那里(RunOnce)写的程序入口。  
  Top

9 楼mv66_ren(didi[迪迪])回复于 2002-07-31 22:05:05 得分 0

你的应用程序正在运行,这时突然关机了(由于某种原因);但当你再次开机时,你的应用程序就会接着  
   
  关机前运行。(我看类似Word)下面是其实现原理:当Windows启动的时候,它自动读取注册表的  
   
  HKLM\...\RunOnce建底下的子键,并运行该子键所对应的程序,然后把该子键删除。  
  为了能调用这个方法,它必须声明在你主窗体的Class下:  
  private  
   
      procedure   WMEndSession(var   Msg:TWMEndSession);   message   WM_ENDSESSION;{这应该是一个Windows  
   
  要关闭的消息}Top

10 楼fermium(列御寇)回复于 2002-07-31 22:06:32 得分 0

嘿嘿,顺便学了一招Top

11 楼lybdata(天下)回复于 2002-07-31 22:11:51 得分 0

也不太准确,请多指正。  
  The   following   example   shows   how   to   tell   Windows   to   relaunch   your   application   when   Windows   starts   up   if   it   was   running   when   the   system   shut   down.   When   Windows   starts   up,   it   launches   each   application   listed   in   the   RunOnce   key   and   then   deletes   the   entry   for   that   application.     Therefore,   you   do   not   need   to   remove   the   entry   written   here.  
  翻译一下:  
  下面的例子显示:当你的程序运行而系统关闭,这时当你重新启动windows时,该程序重新启动。当windows启动时,他把每个应用程序列表放置在runonce键中,然后删除应用程序的入口   ,但是你不必删除写在这里的键值Top

12 楼chons(不羁之城)回复于 2002-08-01 13:21:41 得分 0

谢谢各位了,只是有一点我不明白,当程序执行后,它是如何删除注册表里的这些东西?代码里好像没有啊?Top

13 楼initora(冰红茶.WiKi)回复于 2002-08-01 14:17:41 得分 50

The   following   example   shows   how   to   tell   Windows   to   relaunch   your   application   when   Windows   starts   up   if   it   was   running   when   the   system   shut   down.   When   Windows   starts   up,   it   launches   each   application   listed   in   the   RunOnce   key   and   then   deletes   the   entry   for   that   application.     Therefore,   you   do   not   need   to   remove   the   entry   written   here.  
   
  下面的例子显示了假如你的应用程序在系统关闭时处在运行状态,如何告诉Windows启动时重新载入你的应用程序.当Windows启动时,它装载列示在RunOnce键的每一个应用程序然后删除该应用程序的条目(key).因此,你不必自己去删除这里所写的条目(就是key了).  
   
                                                                                --什么翻译都有,快faint了!Top

14 楼slwqw(四大名捕之追杀令)回复于 2002-08-01 14:58:10 得分 0

"它是如何删除注册表里的这些东西",我上面不是已经说了吗???“当Windows..............运行该子键所对应的程序,然后把该子键删除。”  
  是Windows去删除,而不是程序本身去删除。Top

15 楼caochen(陈陈)回复于 2002-08-01 15:48:32 得分 50

The   following   example   shows   how   to   tell   Windows   to   relaunch   your   application   when   Windows   starts   up   if   it   was   running   when   the   system   shut   down.   When   Windows   starts   up,   it   launches   each   application   listed   in   the   RunOnce   key   and   then   deletes   the   entry   for   that   application.     Therefore,   you   do   not   need   to   remove   the   entry   written   here.  
   
  下面这个例子是让Windows如何在启动的时候重新装在当Windows关闭时还在运行的程序。当Windows启动时,它将运行每一个在RunOnce键值里面所列出的程序,然后删除改应用程序的条目,因此,你不需要在这里写删除键值的程序。  
  Top

相关问题

  • 这几句英文是什么意思?
  • 求delphi英文文章!
  • ^这个符号在Delphi什么意思?
  • DELphi 的警告是什么意思??
  • 不好意思,delphi+mssql中不明白。
  • 不好意思,请问'C++'用英文究竟怎么读?
  • 【 英文地址PO# MCM中的MCM是什么意思?请教! 】
  • MIS ,GIS都是什么意思?是那些英文的缩写?
  • 这几个英文名词是什么意思?
  • ODBC 是什么意思,其原英文是什么?

关键词

  • 应用程序
  • windows
  • application
  • 翻译
  • 程序
  • 删除
  • 启动
  • 运行
  • runonce
  • 键值

得分解答快速导航

  • 帖主:chons
  • initora
  • caochen

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo