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;  

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

Delphi获取系统当前进程名和进程ID

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

获取系统当前进程名和进程ID,注意在编写本单元时,应注意引用"TLHelp32"单元"use TLHelp32".

delphi代码
  1. procedure TForm1.Button1Click(Sender: TObject);   
  2. var  
  3.   ProcessName : string//进程名   
  4.   ProcessID  : integer//进程表示符   
  5.   i : integer;   
  6.   ContinueLoop:BOOL;   
  7.   FSnapshotHandle:THandle; //进程快照句柄   
  8.   FProcessEntry32:TProcessEntry32; //进程入口的结构体信息   
  9. begin  
  10.   FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); //创建一个进程快照   
  11.   FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);   
  12.   ContinueLoop:=Process32First(FSnapshotHandle,FProcessEntry32); //得到系统中第一个进程   
  13.   //循环例举   
  14.   while ContinueLoop  do  
  15.   begin  
  16.     ProcessName := FProcessEntry32.szExeFile;   
  17.     ProcessID := FProcessEntry32.th32ProcessID;   
  18.     Listbox.Items.add('应用程序名 :'+ProcessName +'#进程ID:'+ inttostr(ProcessID));   
  19.     ContinueLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);   
  20.   end;   
  21. end;  

图片附件(缩略图):
fek}k2iwo2$38p8atn}wvp4.jpg

大小: 61.72 K
尺寸: 380 x 336
浏览: 11 次
点击打开新窗口浏览全图

该日志标签: 系统, 进程名, 进程id, 进程, tlhelp32

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字符统计和汉字统计

该日志由 samool 发表于 2007-10-21 10:31 PM

delphi代码
  1. procedure TForm1.btn1Click(Sender: TObject);   
  2. var i,e,c:integer;   
  3.     s:string;   
  4. begin    
  5.     s:=mmo1.Text ;   
  6.     e:=0;c:=0;   
  7.     for i:=1 to length(s) do  
  8.     begin  
  9.       if(ord(s[i])>=33)and(ord(s[i])<=126then  
  10.       begin  
  11.       inc(e);   
  12.       Label1.Caption:=inttostr(e);  //字符个数  
  13.       end  
  14.       else  if (ord(s[i])>=127then  
  15.       begin  
  16.       inc(c);   
  17.       Label2.Caption:=inttostr(c div 2);  //汉字个数 
  18.       end;   
  19.     end;   
  20. end;  

该日志标签: 汉字, 字符, 统计

VB6如何访问.NET WebService服务

该日志由 samool 发表于 2007-10-18 4:53 PM

首先安装Microsoft SoapToolkit,因为VB自身不支持WebService,需要安装SoapTookit后能调用WebService。

下载SoapTookit3.0

然后在VB6中点菜单“工程”—“引用”-把“Microsoft Soap Type Libray v3.0” 打上钩就可以了。

     Dim mysoap As New SoapClient30
     mysoap.MSSoapInit ("http://www.samool.com/soap/Webservice.asmx?WSDL")
     Label1.Caption = mysoap.helloWorld(Text1.Text)

按上面方法直接调用WebService函数就OK了。

该日志标签: vb6, .net, webservice, soaptoolkit, soapclient

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, 验证, 登录, 函数

如何使用BHO定制你的Internet Explorer浏览器

该日志由 samool 发表于 2007-10-15 10:26 AM

  有时,你可能需要一个定制版本的浏览器。在这种情况下,你可以自由地把一些新颖但又不标准的特征增加到一个浏览器上。结果,你最终有的只是一个新但不标准的浏览器。Web浏览器控件只是浏览器的分析引擎。这意味着仍然存在若干的与用户接口相关的工作等待你做――增加一个地址栏,工具栏,历史记录,状态栏,频道栏和收藏夹等。如此,要产生一个定制的浏览器,你可以进行两种类型的编程――一种象微软把Web浏览器控件转变成一个功能齐全的浏览器如Internet Explorer;一种是在现有的基础上加一些新的功能。如果有一个直接的方法定制现有的Internet Explorer该多好?BHO(Browser Helper Objects,我译为"浏览器帮助者对象",以下皆简称BHO)正是用来实现此目的的。

» 阅读该日志全文...

该日志标签: bho, ie, 浏览器, 插件

Browser Helper Object,浏览器辅助对象BHO介绍

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

    BHO是微软推出的作为浏览器对第三方程序员开放交互接口的业界标准,通过简单的代码就可以进入浏览器领域的“交互接口”(INTERACTIVED Interface)。通过这个接口,程序员可以编写代码获取浏览器的行为,比如“后退”、“前进”、“当前页面”等,利用BHO的交互特性,程序员还可以用代码控制浏览器行业,比如修改替换浏览器工具栏,添加自己的程序按钮等(见图1)。这些在系统看来都是没有问题的。BHO原来的目的是为了更好的帮助程序员打造个性化浏览器,以及为程序提供更简洁的交互功能,现在很多IE个性化工具就是利用BHO的来实现。

» 阅读该日志全文...

该日志标签: 微软, bho, 接口, 插件, 浏览器

bho插件开发:flash上弹出浮动工具条

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

bho插件开发:flash上弹出浮动工具条

» 阅读该日志全文...

该日志标签: bho, flash, 工具条

Browser Helper Objects: The Browser the ...

该日志由 samool 发表于 2007-10-15 9:49 AM

There are sometimes circumstances in which you need a more or less specialized version of the browser. Sometimes you work around this by developing a completely custom module built on top of the WebBrowser control, complete with buttons, labels, and whatever else the user interface requires. In this case, you're free to add to that browser any new, nonstandard feature you want. But what you actually have is just a new, nonstandard browser. The WebBrowser control is just the parsing engine of the browser. This means there still remains a number of UI-related tasks for you to do: adding an address bar, toolbar, history, status bar, channels, and favorites, just to name a few. So, to create a custom browser you have to write two types of code: the code that transforms the WebBrowser control into a full-fledged browser like Microsoft® Internet Explorer, and the code that implements the new features you want it to support. Wouldn't it be nice if there was a straightforward way to customize Internet Explorer instead? Browser Helper Objects (BHO) do just that.

» 阅读该日志全文...

该日志标签: microsoft, bho, browser