打印本文 打印本文 关闭窗口 关闭窗口
DELPHI开发技巧
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4135  更新时间:2009/4/23 18:29:00  文章录入:mintao  责任编辑:mintao
有如下格式:

[+|-]nnn…[.]nnn…[<+|-><E|e><+|->nnnn]

strtoint (const S:string):longint 将数字字符串转换成整数,字符串可以是十进制或十六进制格式,如果字符串不是一个合法的数字字符串,系统发生ECONVERTERROR异常

strtointdef (const S:string;default:

longint):longint; 将字符串S转换成数字,如果不能将S转换成数字,strtointdef函数返回参数default的值。

strtotime (const S:string):Tdatetime 将字符串S转换成TDATETIME值,S具有HH:MM:SS[AM|PM]格式,实际的格式与系统的时间相关的全局变量有关。

timetostr (time:Tdatetime):string; 将参数TIME转换成字符串。转换结果字符串的格式与系统的时间相关常量的设置有关。

 

◇[DELPHI]程序不出现在ALT+CTRL+DEL

在implementation后添加声明:

function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer; stdcall; external ''''KERNEL32.DLL'''';

RegisterServiceProcess(GetCurrentProcessID, 1);//隐藏

RegisterServiceProcess(GetCurrentProcessID, 0);//显示

用ALT+DEL+CTRL看不见

 

◇[DELPHI]程序不出现在任务栏

uses windows

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]如何判断拨号网络是开还是关

if GetSystemMetrics(SM_NETWORK) AND $01 = $01 then

showmessage(''''在线!'''')

else showmessage(''''不在线!'''');

 

◇[DELPHI]实现IP域名的转换

function GetDomainName(Ip:string):string;

var

pH:PHostent;

data:twsadata;

ii:dword;

begin

WSAStartup($101, Data);

ii:=inet_addr(pchar(ip));

pH:=gethostbyaddr(@ii,sizeof(ii),PF_INET);

if (ph<>nil) then

result:=pH.h_name

else

result:='''''''';

WSACleanup;

end;

 

◇[DELPHI]处理“右键菜单”方法

var

reg: TRegistry;

begin

reg := TRegistry.Create;

reg.RootKey:=HKEY_CLASSES_ROOT;

reg.OpenKey(''''*\shell\check\command'''', true);

reg.WriteString('''''''', ''''"'''' + application.ExeName + ''''" "%1"'''');

reg.CloseKey;

reg.OpenKey(''''*\shell\diary'''', false);

reg.WriteString('''''''', ''''操作(&C)'''');

reg.CloseKey;

reg.Free;

showmessage(''''DONE!'''');

end;

 

◇[DELPHI]发送虚拟键值ctrl V

procedure sendpaste;

begin

keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), 0, 0);

keybd_event(ord(''''V''''), MapVirtualKey(ord(''''V''''), 0), 0, 0);

keybd_event(ord(''''V''''), MapVirtualKey(ord(''''V''''), 0), KEYEVENTF_KEYUP, 0);

keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), KEYEVENTF_KEYUP, 0);

end;

 

◇[DELPHI]当前的光驱的盘符

procedure getcdrom(var cd:char);

var

str:string;

drivers:integer;

driver:char;

i,temp:integer;

begin

drivers:=getlogicaldrives;

temp:=(1 and drivers);

for i:=0 to 26 do

begin

if temp=1 then

begin

driver:=char(i+integer(''''a''''));

str:=driver+'''':'''';

if getdrivetype(pchar(str))=drive_cdrom then

begin

cd:=driver;

exit;

end;

end;

drivers:=(drivers shr 1);

temp:=(1 and drivers);

end;

end;

 

◇[DELPHI]字符的加密与解密

function cryptstr(const s:string; stype: dword):string;

var

i: integer;

fkey: integer;

begin

result:='''''''';

case stype of

上一页  [1] [2] [3] [4] [5] [6] [7]  下一页

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