电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> delphi技术>>Delphi基础开发技巧(6):

Delphi基础开发技巧(6)

来源:远方网络 | 2005-12-31 9:27:58 | (有1952人读过)

[DELPHI]安装程序如何添加到Uninstall列表

操作注册表,如下:

1.在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall键下建立一个主键,名称任意。

例HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyUninstall

2.在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyUnistall下键两个串值,

这两个串值的名称是特定的:DisplayName和UninstallString。

3.给串DisplayName赋值为显示在“删除应用程序列表”中的名称,如'Aiming Uninstall one';

给串UninstallString赋值为执行的删除命令,如 C:\WIN97\uninst.exe -f"C:\TestPro\aimTest.isu"

◇[DELPHI]截获WM_QUERYENDSESSION关机消息

type

TForm1 = class(TForm)

procedure WMQueryEndSession(var Message: TWMQueryEndSession); message WM_QUERYENDSESSION;

procedure CMEraseBkgnd(var Message:TWMEraseBkgnd);Message WM_ERASEBKGND;

private

{ Private declarations }

public

{ Public declarations }

end;

procedure TForm1.WMQueryEndSession(var Message: TWMQueryEndSession);

begin

Showmessage('computer is about to shut down');

end;

[DELPHI]获取网上邻居

procedure getnethood();//NT做服务器,WIN98上调试通过。

var

a,i:integer;

errcode:integer;

netres:array[0..1023] of netresource;

enumhandle:thandle;

enumentries:dword;

buffersize:dword;

s:string;

mylistitems:tlistitems;

mylistitem:tlistitem;

alldomain:tstrings;

begin //listcomputer is a listview to list all computers;controlcenter is a form.

alldomain:=tstringlist.Create ;

with netres[0] do begin

dwscope :=RESOURCE_GLOBALNET;

dwtype :=RESOURCETYPE_ANY;

dwdisplaytype :=RESOURCEDISPLAYTYPE_DOMAIN;

dwusage :=RESOURCEUSAGE_CONTAINER;

lplocalname :=nil;

lpremotename :=nil;

lpcomment :=nil;

lpprovider :=nil;

end; // 获取所有的域

errcode:=wnetopenenum(RESOURCE_GLOBALNET,RESOURCETYPE_ANY,RESOURCEUSAGE_CONTAINER,@netres[0],enumhandle);

if errcode=NO_ERROR then begin

enumentries:=1024;

buffersize:=sizeof(netres);

errcode:=wnetenumresource(enumhandle,enumentries,@netres[0],buffersize);

end;

a:=0;

mylistitems :=controlcenter.lstcomputer.Items ;

mylistitems.Clear ;

while (string(netres[a].lpprovider)<>'') and (errcode=NO_ERROR) do

begin

alldomain.Add (netres[a].lpremotename);

a:=a+1;

end;

wnetcloseenum(enumhandle);

// 获取所有的计算机

mylistitems :=controlcenter.lstcomputer.Items ;

mylistitems.Clear ;

for i:=0 to alldomain.Count-1 do

begin

with netres[0] do begin

dwscope :=RESOURCE_GLOBALNET;

dwtype :=RESOURCETYPE_ANY;

dwdisplaytype :=RESOURCEDISPLAYTYPE_SERVER;

dwusage :=RESOURCEUSAGE_CONTAINER;

lplocalname :=nil;

lpremotename :=pchar(alldomain[i]);

lpcomment :=nil;

lpprovider :=nil;

end;

ErrCode:=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_ANY,RESOURCEUSAGE_CONTAINER,@netres[0],EnumHandle);

if errcode=NO_ERROR then

begin

EnumEntries:=1024;

BufferSize:=SizeOf(NetRes);

ErrCode:=WNetEnumResource(EnumHandle,EnumEntries,@NetRes[0],BufferSize);

end;

a:=0;

while (string(netres[a].lpprovider)<>'') and (errcode=NO_ERROR) do

begin

mylistitem :=mylistitems.Add ;

mylistitem.ImageIndex :=0;

mylistitem.Caption :=uppercase(stringreplace(string(NetRes[a].lpremotename),'\\','',[rfReplaceAll]));

a:=a+1;

end;

wnetcloseenum(enumhandle);

end;

end;

delphi技术热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号