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

Delphi基础开发技巧(7)

来源:远方网络 | 2005-12-31 9:28:15 | (有1708人读过)

[DELPHI]获取某一计算机上的共享目录

procedure getsharefolder(const computername:string);

var

errcode,a:integer;

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

enumhandle:thandle;

enumentries,buffersize:dword;

s:string;

mylistitems:tlistitems;

mylistitem:tlistitem;

mystrings:tstringlist;

begin

with netres[0] do begin

dwscope :=RESOURCE_GLOBALNET;

dwtype :=RESOURCETYPE_DISK;

dwdisplaytype :=RESOURCEDISPLAYTYPE_SHARE;

dwusage :=RESOURCEUSAGE_CONTAINER;

lplocalname :=nil;

lpremotename :=pchar(computername);

lpcomment :=nil;

lpprovider :=nil;

end; // 获取根结点

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

if errcode=NO_ERROR then

begin

EnumEntries:=1024;

BufferSize:=SizeOf(NetRes);

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

end;

wnetcloseenum(enumhandle);

a:=0;

mylistitems:=controlcenter.lstfile.Items ;

mylistitems.Clear ;

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

begin

with mylistitems do

begin

mylistitem:=add;

mylistitem.ImageIndex :=4;

mylistitem.Caption :=extractfilename(netres[a].lpremotename);

end;

a:=a+1;

end;

end;

◇[DELPHI]得到硬盘序列号

var SerialNum : pdword; a, b : dword; Buffer : array [0..255] of char;

begin

if GetVolumeInformation('c:\', Buffer, SizeOf(Buffer), SerialNum, a, b, nil, 0) then Label1.Caption := IntToStr(SerialNum^);

end;

◇[DELPHI]MEMO的自动翻页

Procedure ScrollMemo(Memo : TMemo; Direction : char);

begin

case direction of

'd': begin

SendMessage(Memo.Handle, { HWND of the Memo Control }

WM_VSCROLL, { Windows Message }

SB_PAGEDOWN, { Scroll Command }

0) { Not Used }

end;

'u' : begin

SendMessage(Memo.Handle, { HWND of the Memo Control }

WM_VSCROLL, { Windows Message }

SB_PAGEUP, { Scroll Command }

0); { Not Used }

end;

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

ScrollMemo(Memo1,'d'); //上翻页

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

ScrollMemo(Memo1,'u'); //下翻页

end;

◇[DELPHI]DBGrid中回车到下个位置(Tab键)

procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);

begin

if Key = #13 then

if DBGrid1.Columns.Grid.SelectedIndex < DBGrid1.Columns.Count - 1 then

DBGrid1.Columns[DBGrid1.Columns.grid.SelectedIndex + 1].Field.FocusControl

else

begin

Table1.next;

DBGrid1.Columns[0].field.FocusControl;

end;

end;



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

 

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

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