打印本文 打印本文 关闭窗口 关闭窗口
DELPHI基础开发技巧(不看后悔!)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3424  更新时间:2009/4/23 18:35:37  文章录入:mintao  责任编辑:mintao
var drive:char;
cdromID:integer;
begin
for drive:=''''d'''' to ''''z'''' do
begin
cdromID:=GetDriveType(pchar(drive+'''':\''''));
if cdromID=5 then showmessage(''''你的光驱为:''''+drive+''''盘!'''');
end;
end;
◇[DELPHI]检测声卡
if auxGetNumDevs()<=0 then showmessage(''''No soundcard found!'''') else showmessage(''''Any soundcard found!'''');
◇[DELPHI]在字符串网格中画图
StringGrid.OnDrawCell事件
with StringGrid1.Canvas do 
Draw(Rect.Left, Rect.Top, Image1.Picture.Graphic); 
◇[SQL SERVER]SQL中代替Like语句的另一种写法
比如查找用户名包含有"c"的所有用户, 可以用 
use mydatabase 
select * from table1 where username like''''%c%" 
下面是完成上面功能的另一种写法: 
use mydatabase 
select * from table1 where charindex(''''c'''',username)>0 
这种方法理论上比上一种方法多了一个判断语句,即>0, 但这个判断过程是最快的, 我想信80%以上的运算都是花在查找字 
符串及其它的运算上, 所以运用charindex函数也没什么大不了. 用这种方法也有好处, 那就是对%,|等在不能直接用like 
查找到的字符中可以直接在这charindex中运用, 如下: 
use mydatabase 
select * from table1 where charindex(''''%'''',username)>0 
也可以写成: 
use mydatabase 
select * from table1 where charindex(char(37),username)>0 
ASCII的字符即为% 
◇[DELPHI]SQL显示多数据库/表
SELECT DISTINCT A.bianhao,a.xingming, b.gongzi FROM "jianjie.dbf" a, "gongzi.DBF" b 
WHERE A.bianhao=b.bianhao
◇[DELPHI]RFC(Request For Comment)相关
IETF(Internet Engineering Task Force)维护RFC文档http://www.ietf.cnri.reston.va.us
RFC882:报文头标结构
RFC1521:MIME第一部分,传输报文方法
RFC1945:多媒体文档传输文档
◇[DELPHI]TNMUUProcessor的使用
var inStream,outStream:TFileStream;
begin
inStream:=TFileStream.create(infile.txt,fmOpenRead);
outStream:=TFileStream(outfile.txt,fmCreate);
NMUUE.Method:=uuCode;{UUEncode/Decode}
//NMUUE.Method:=uuMIME;{MIME}
NMUUE.InputStream:=InStream;
NMUUE.OutputStream:=OutStream;
NMUUE.Encode;{编码处理}
//NMUUE.Decode;{解码处理}
inStream.free;
outStream.free;
end;
◇[DELPHI]TFileStream的操作
//从文件流当前位置读count字节到缓冲区BUFFER
function read(var buffer;count:longint):longint;override;
//将缓冲区BUFFER读到文件流中
function write(const buffer;count:longint):longint;override;
//设置文件流当前读写指针为OFFSET
function seek(offset:longint;origin:word):longint;override;
origin={soFromBeginning,soFromCurrent,soFromEnd}
//从另一文件流中当前位置复制COUNT到当前文件流当前位置
function copyfrom(source:TStream;count:longint):longint;
//读指定文件到文件流
var myFStream:TFileStream;
begin
myFStream:=TFileStream.create(OpenDialog1.filename,fmOpenRead);
end;
[JavaScript]检测是否安装IE插件Shockwave&Quicktime


-----------------

谢谢你耐心看完,你有技巧了,希望继续贴出来!

上一页  [1] [2] [3] [4] [5] 

打印本文 打印本文 关闭窗口 关闭窗口