Delphi常用的函数库

该日志由 samool 发表于 2008-03-11 10:24 AM

Delphi常用的函数库,引用作者的话“今天在整理以前写过的代码,发现有些函数还是挺实用的,决定将其贴到Blog上,与众多好友一起分享。”

源文地址:http://blog.csdn.net/chris_mao/archive/2007/11/01/1862017.aspx

» 阅读该日志全文...

该日志标签: 函数

汇编级超快字符串替换函数

该日志由 samool 发表于 2007-10-23 3:19 PM

 用这个函数进行字符串替换操作,比Delphi自带的ReplaceString要快N倍,效率一流,非常快,不愧为汇编级函数操作,哈哈.

下载函数单元文件:[attach=1619]

» 阅读该日志全文...

该日志标签: 汇编, 函数, 字符, 替换

IsNumeric 判断字符串是否为数字

该日志由 samool 发表于 2007-10-22 10:17 AM

IsNumeric 判断字符串是否为数字,如果是数字返回true,如果包含有汉字或字符的话返回false.  由于Delphi本身没有IsNumeric这个函数,不像其它语言,这个函数相当于Java的IsNaN函数。

delphi代码
  1. function  IsNumeric(AStr:   string):   Boolean;   
  2. var  
  3.       Value:   Double;   
  4.       Code:   Integer;   
  5. begin  
  6.       Val(AStr,   Value,   Code);   
  7.       result   :=   Code   =   0;   
  8. end;  

该日志标签: 函数, 字符串, 数字, 判断

WinExecAndWait32调用外部程序,等待外部程序运行完成

该日志由 samool 发表于 2007-10-22 9:45 AM

 调用外部程序,等待外部程序运行完成,相当于Showmodal功能,呵呵

delphi代码
  1. function WinExecAndWait32(FileName: string; Visibility: Boolean): integer;   
  2. var  
  3.   zAppName: array[0..512of char//存放应用程序名   
  4.   StartupInfo: TStartupInfo;   
  5.   ProcessInfo: TProcessInformation;   
  6.   exitCode: Dword;   
  7.   aVisibility: integer;   
  8. begin  
  9.   StrPCopy(zAppName, FileName);   
  10.   FillChar(StartupInfo, Sizeof(StartupInfo), #0);   
  11.   //给StartupInfo结构体赋值   
  12.   StartupInfo.cb := Sizeof(StartupInfo);   
  13.   StartupInfo.dwFlags := STARTF_USESHOWWINDOW;   
  14.   if Visibility then  
  15.     aVisibility := 1  
  16.   else  
  17.     aVisibility := 0;   
  18.   
  19.   StartupInfo.wShowWindow := aVisibility;   
  20.   //调用CreateProcess 创建进程,执行指定的可执行文件   
  21.   if not CreateProcess(nil, zAppName, nilnilfalse  
  22.     , CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS   
  23.     , nilnil, StartupInfo, ProcessInfo) then  
  24.     Result := -1  
  25.   else  
  26.   begin  
  27.     //等待可执行文件退出   
  28.     WaitforSingleObject(ProcessInfo.hProcess, INFINITE);   
  29.     //得到进程终止状态码   
  30.     GetExitCodeProcess(ProcessInfo.hProcess, exitCode);   
  31.     result := Exitcode;   
  32.   end;   
  33. end;  

该日志标签: 函数, 程序, 进程, 运行, winexec

Delphi集成Windows验证登录函数

该日志由 samool 发表于 2007-10-17 3:08 PM

The first and biggest of these restrictions is that on Windows NT and Windows 2000, the process that is calling LogonUser must have the SE_TCB_NAME privilege (in User Manager, this is the ""Act as part of the Operating System"" right). The SE_TCB_NAME privilege is very powerful and should not be granted to any arbitrary user just so that they can run an application that needs to validate credentials. The recommended method is to call LogonUser from a service that is running in the local system account, because the local system account already has the SE_TCB_NAME privilege.  

» 阅读该日志全文...

该日志标签: windows, 验证, 登录, 函数

Delphi函数返回多个值

该日志由 samool 发表于 2007-10-11 4:49 PM

今天在搞一个程序中,要求返回多个值,我知道用数组使用,但以前还没有做过,于是在网上找了一下,得到这个东东,原来自己定义一个类型,然后将函数的类型设为自定义类型就可以了,我定义的是字符串数组,函数返回值当然是多个字符串了,呵呵。

可以函数过程中设定返回数组的大小,SetLength (result,5)就可以。

» 阅读该日志全文...

该日志标签: delphi, 函数, 数组, 字符串

ASP数据库操作常用函数集

该日志由 samool 发表于 2007-09-21 10:10 AM

 ASP数据库操作常用函数集,经典的东西收藏备用。

» 阅读该日志全文...

该日志标签: asp, 数据库, 函数

SplitString分隔函数

该日志由 samool 发表于 2006-05-27 6:00 PM

function SplitString(Source, Deli: string ): TStringList;
var
    EndOfCurrentString: byte;
    StringList:TStringList;
begin
    StringList:=TStringList.Create;
    while Pos(Deli, Source)>0 do
    begin
        EndOfCurrentString := Pos(Deli, Source);
        StringList.add(Copy(Source, 1, EndOfCurrentString - 1));
        Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);
    end;
    Result := StringList;
    StringList.Add(source);
end;

该日志标签: 函数

delphi中常用的字符处理函数

该日志由 samool 发表于 2006-05-08 10:44 AM

全是常用的字符处理函数,收集起来,以备后用。:)

» 阅读该日志全文...

该日志标签: delphi, 字符, 函数