当前位置:编程学习 > C#/ASP.NET >>

帮忙看下这些代码是什么意思呢?谢谢了。

unit Unit1;

interface

uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls,registry, ExtCtrls, shellapi;

type
   TForm1 = class(TForm)
     Timer1: TTimer;
     Label1: TLabel;
     Label2: TLabel;
     procedure FormCreate(Sender: TObject);
     procedure Timer1Timer(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;

var
   Form1: TForm1;
   reg:tregistry;
   hwnd:thandle;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
//application.showmainform=false //隐藏窗体。这里是演示,就不隐藏了。
reg:=Tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',true); //true应该是覆盖。
reg.writestring('scanregistry','ad.exe');      //以上三行就是写入注册表的启动项。
reg.closekey;
reg.free;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
hwnd:=findwindow('IEframe',nil);//调用Findwindow函数来查找浏览器是否运行。
if hwnd<>0 then //如果浏览器正在运行,那么...
shellexecute(0,'open','iexplore.exe','http://www.qq.com,'',SW_SHOWNORMAL);
//打开www.hack520.org这个网站,这里shellexecute的用法跟VB的一样。
end;

end. --------------------编程问答-------------------- 这段代码你到底是哪些不明白,也没有个标注。 --------------------编程问答-------------------- 这段程序有什么用呢?谢谢。 --------------------编程问答-------------------- 应该是
程序启动,往注册表启动项里面加入启动 'ad.exe'

然后,如果浏览器在运行,就打开http://www.qq.com --------------------编程问答--------------------
引用 3 楼 net_lover 的回复:
应该是
程序启动,往注册表启动项里面加入启动 'ad.exe'

然后,如果浏览器在运行,就打开http://www.qq.com

创建窗体然后就是上面的: --------------------编程问答--------------------
引用楼主 xiaosan00000 的回复:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,registry, ExtCtrls, shellapi;

type
  TForm1 = class(TForm)
  Ti……

上部分是:向注册表中写入“键值”
下部分是:打开一个“网址”
--------------------编程问答--------------------
create的时候写注册表,要在开机时候运行ad.exe
同时如果IEframe运行,打开http://www.qq.com网站。
补充:.NET技术 ,  其他语言
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,