摘要载入中…    请稍等…












内容载入中…    请稍等…

如长时间看不到内容,请关闭浏览器,重新打开此页!

芯友首页 应用软件 编程开发 网络硬件 资源下载 动漫音乐 精美图库 芯友论坛 视频教程 电脑技术QQ群:72845454
 ★★photoshop学友-史上最强播放器★★
 位置:编程开发>Deiphi>Deiphi实例教程
◎→ 本类最新
在DELPHI中用线程排序
在Delphi中使用Queued Component
作非常规程序菜单掌握delphi
执行一个外部程序并等待它的完成
在应用程序中跟踪MOUSE的坐标
五子棋源代码
显示密码的原理
◎→相关资源
C语言入门视频教程
C#编程WinForm入门视频
Asp.net入门视频教程下载
VC++编程视频教程下载
VB窗体文章
HTML入门教程
Deiphi实例教程
Deiphi窗体文章
Deiphi数据库编程
Deiphi网络编程
Deiphi图形图象文章
Deiphi系统文件
◎→ 热门资源
用拼音首字符来实现检索功能
将JPEG文件转为Windows墙纸
对DELPHI图形编辑技巧二则
Delphi编程实现3D图形修饰技术(2
Delphi编程实现3D图形修饰技术
Delphi实现通用的定时自动关机程
Delphi实现通用的定时自动关机程

教你在DELPHI中基础开发技巧(10)


日期:2008-10-20 22:07:51    来源:
   

教你在DELPHI中基础开发技巧BoardBiosDate:'+^I+string(Pchar(Ptr($FFFF5))));
Add('MainBoardBiosSerialNo:'+^I+string(Pchar(Ptr($FEC71))));
end;

  ◇[DELPHI]动态建立MSSQL别名
procedure Tform1.Button1Click(Sender: TObject);
var MyList: TStringList;
begin
MyList := TStringList.Create;
try
with MyList do
begin
Add('SERVER NAME=210.242.86.2');
Add('DATABASE NAME=db');
Add('USER NAME=sa');
end;
Session1.AddAlias('TESTSQL', 'MSSQL', MyList); //ミMSSQL
Session1.SaveConfigFile;
finally
MyList.Free;
Session1.Active:=True;
Database1.DatabaseName:='DB';
Database1.AliasName:='TESTSQL';
Database1.LoginPrompt:=False;
Database1.Params.Add('USER NAME=sa');
Database1.Params.Add('PASSWORD=');
Database1.Connected:=True;
end;
end;

procedure Tform1.Button2Click(Sender: TObject);
begin
Database1.Connected:=False;
Session1.DeleteAlias('TESTSQL'); 
end;

  ◇[DELPHI]播放背景音乐
uses mmsystem
//播放音乐
MCISendString('OPEN e:\1.MID TYPE SEQUENCER ALIAS NN', '', 0, 0);
MCISendString('PLAY NN FROM 0', '', 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);
end;
//停止播放
MCISendString('OPEN e:\1.MID TYPE SEQUENCER ALIAS NN', '', 0, 0);
MCISendString('STOP NN', '', 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);

  ◇[DELPHI]接口和类的一个范例代码
Type{接口和类申明:区别在于不能在接口中申明数据成员、任何非公有的方法、公共方法不使用PUBLIC关键字}
Isample=interface//定义Isample接口
function getstring:string;
end;
Tsample=class(TInterfacedObject,Isample)
public
function getstring:string;
end;
//function定义
function Tsample.getstring:string;
begin
result:='what show is ';
end;
//调用类对象
var sample:Tsample;
begin
sample:=Tsample.create;
showmessage(sample.getstring+'class object!');
sample.free;
end;
//调用接口
var sampleinterface:Isample;
sample:Tsample;
begin
sample:=Tsample.create;
sampleInterface:=sample;//Interface的实现必须使用class
{以上两行也可表达成sampleInterface:=Tsample.create;}
showmessage(sampleInterface.getstring+'Interface!');
//sample.free;{和局部类不同,Interface中的类自动释放}
sampleInterface:=nil;{释放接口对象}
end;

  ◇[DELPHI]任务条就看不当程序
var
Extendedstyle : Integer;
begin
Application.Initialize;
Extendedstyle := GetWindowLong (Application.Handle, GWL_EXstyle);
SetWindowLong(Application.Handle, GWL_EXstyle, Extendedstyle OR WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
Application.Createform(Tform1, form1);
Application.Run;
end.

  ◇[DELPHI]ALT+CTRL+DEL看不到程序
在implementation后添加声明:
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL';
RegisterServiceProcess(GetCurrentProcessID, 1);//隐藏
RegisterServiceProcess(GetCurrentProcessID, 0);//显示

  ◇[DELPHI]检测光驱符号
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
这种方法理论上比上一种方法多了一个判断语句,即>  [1]
Tags: 

芯友网版权所有 1999-2006 | 著作权与商标声明 | 法律声明 | 服务条款 | 隐私声明 | 联系我们