0 Comments

Delphi基础开发技巧(7)

发布于:2014-04-23  |   作者:广州网站建设  |   已聚集:人围观
[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;
标签:
飞机