孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
上一页 1 ··· 22 23 24 25 26

2008年9月10日

摘要: procedure ReplaceStrToStrings(AStrings:TStrings;sToken,sRep:string);vari,j:integer;beginfor i:=0 to AStrings.count-1 dobegins:=AStrings[i];j:=Pos(sToken,s);if (j>0) thenbegins:=Copy(s,1,j-1)+sRep+Copy(s,j+length(sToken),length(s)-(j+length(sToken)));AStrings[i] :=s;end;end;end; 阅读全文
posted @ 2008-09-10 18:39 孤独的猫 阅读(203) 评论(0) 推荐(0) 编辑

摘要: procedure DeleteFiles(Handle:THandle;Source:string);varFO:TShFileOpStruct;beginFillChar(FO,Sizeof(FO),#0);FO.wnd:=handle;FO.wFunc :=FO_Delete;FO.flags:=FOF_NOCONFINFORMATION;FO.pFrom :=PChar(Source);SHFileOperation(FO);end;end; 阅读全文
posted @ 2008-09-10 18:38 孤独的猫 阅读(148) 评论(0) 推荐(0) 编辑

摘要: procedure MoveFile(Handle:THandle;Source,Dest:string);varFO:TShFileOpStruct;beginFillChar(FO,Sizeof(FO),#0);FO.wnd :=Handle;FO.wFunc :=FO_Move;FO.flags :=FOF_NoCONFIFMATION;FO.pFrom :=pchar(Source+#0#0);PO.pTo :=pchar(Dest+#0#0);ShFileOperation(FO);end; 阅读全文
posted @ 2008-09-10 18:36 孤独的猫 阅读(105) 评论(0) 推荐(0) 编辑

摘要: //分解文件夹 SDir:源目录名 DDir:目的目录名 SQZ:生成的子目录(前)后缀名//SExt:文件类型 MNum:每个文件夹的文件数目 B:SQZ为前缀还是后缀名procedure CutDir(SDir,DDir,SQZ,SExt:string;MNum:integer;B:Boolean;handle:THandle);vari,iFileCount,iFileNum,iDirCount,iDirNum:integer;tsr:TStringList;DFileName,SFileName:string;bSearch:Boolean;beginbSearch:=False;ts 阅读全文
posted @ 2008-09-10 18:35 孤独的猫 阅读(271) 评论(0) 推荐(0) 编辑

摘要: function SaveHTMLToStream(Astream:TStream):HResult;varIpStream:IpersistStreamInit;beginwith WebBrower2 dobeginwhile ReadState<>READYSTATE_COMPLETE doForms.Application.ProcessMessages;if Assigned(Document) thenbeginIpStream :=Document as IPersistStreamInit;Result :=IpStream.Save(TStreamAdapter. 阅读全文
posted @ 2008-09-10 17:53 孤独的猫 阅读(223) 评论(0) 推荐(0) 编辑

摘要: procedure UseHtmlDialog(htmlName:string);vara,b:OleVariant;c:integer;begina:=0;b:=0;WebBrowser1.Navigate(htmlName);c:=WebBrowser1.QueryStatusWB(OLECMDID_SELECTALL);if c>0 thenWebBrowser2.ExecWB(OLECMID_SAVEAS,OLECMEXCOPY_DONTPROMPTUSER,EmptyParam,EmptyParam)elseShowmessage('命令不能执行');end; 阅读全文
posted @ 2008-09-10 17:51 孤独的猫 阅读(107) 评论(0) 推荐(0) 编辑

摘要: 首先在uses中加入ActiveX,MSHTML,OleCtrls,SHDocVw,然后编写代码procedure SaveHTMLSourceToFile(const FileName:string;WB:TWebBrowser);varPersistStream:IPersistStreamInit;FileStream:TFileStream;Stream:IStream;SaveResult:HResult;beginPersistStream :=WB.Document as IPersistStreamInit;FileStream :=TFileStream.Create(Fil 阅读全文
posted @ 2008-09-10 17:50 孤独的猫 阅读(580) 评论(0) 推荐(0) 编辑

摘要: procedure SaveHtmlContentToTxt(htmlName,txtName:string);varlpf:IPersistFile;beginWebBrowser1.Navigate(htmlName);lpf:=WebBrowser1.Document sa IPersistFile;lpf.Save(pchar(txtName),True);end; 阅读全文
posted @ 2008-09-10 17:49 孤独的猫 阅读(452) 评论(0) 推荐(0) 编辑

摘要: 需添加UrlMon单元function DownloadFile(Source,Dest:string):boolean;begintryResult :=UrlDownloadFile(nil,pchar(Source),pchar(Dest),0,nil)=0;exceptResult :=False;end;end; 阅读全文
posted @ 2008-09-10 17:48 孤独的猫 阅读(157) 评论(0) 推荐(0) 编辑

摘要: procedure GrayToColor(Bmp:TBitmap);vari,j,uG:integer;beginBmp.PixelFormat:=pf24Bit;for j:=0 to Bmp.Height-1 dobeginp:=Bmp.Scanline[j];for i:=0 to Bmp.Width-1 dobeginuG:=p[3*i];if (0<uG) and (uG<63) thenbeginp[3*i+2]:=0;p[3*i+1]:=254-4*uG;p[3*i]:=255;end;if (64<=uG) and (uG<127) thenbegin 阅读全文
posted @ 2008-09-10 17:47 孤独的猫 阅读(464) 评论(0) 推荐(0) 编辑

摘要: use ShellApi;copyfile(pchar('newfile.txt',pchar('//computername/direction/target.txt'),false); 阅读全文
posted @ 2008-09-10 17:44 孤独的猫 阅读(202) 评论(0) 推荐(0) 编辑

摘要: procedure Invert(Image:TImage);varBMP:TBitmap;beginBMP:=TBitmap.Create;tryBmp.Width :=Image1.Picture.Bitmap.Width;Bmp.Height:=Image1.Picture.Bitmap.Height;Bitblt(Bmp.Canvas.Handle,0,0,Bmp.Width,Bmp.Height,Image.Picture.Bitmap.CanvasHandle,0,0,NoTSRCCCPY);Image.Picture.Bitmap.Assign(Bmp);finallyBmp.F 阅读全文
posted @ 2008-09-10 17:44 孤独的猫 阅读(161) 评论(0) 推荐(0) 编辑

摘要: function SelectDir:stringvarInfo:TBrowseInfo;IDList:PItemIDList;Buffer:pchar;beginresult :='';Buffer:=StrAlloc(MAX_PATH);with Info dobeginhwndOwner:=Application.mainform.handle;pidRoot :=nil;pszDisplayName:=Buffer;lpszTitle:='请选择路径:';uFlags:=BIF_RETURNONLYFSDIRS; //如果加上OR BIF_BROWSEI 阅读全文
posted @ 2008-09-10 17:43 孤独的猫 阅读(113) 评论(0) 推荐(0) 编辑

摘要: 首先添加shlobj单元procedure CreateLink(ExePath,LinkName:WideString);vartmpObject:IUnknown;tmpSLink:IShellLink;PIDL:PItemIDList;tmpPFile:IPersistFile;StartupDirectory:array[0..MAXPATH] of char;LinkFileName:widestring;beginStartupFileName:=ExePath;tmpObject:=CreateObject(CLSID_ShellLink);tmpSLink:=tmpObject 阅读全文
posted @ 2008-09-10 17:42 孤独的猫 阅读(192) 评论(0) 推荐(0) 编辑

摘要: procedure CloseWindow(Flag:integer);varhToken:Thandle;tkp,tkDumb:TTokenPrivileges;DoubInt:dword;beginif Win32PlatForm=VER_PLATFORM_WIN32_NT thenbeginFillChar(tkp,Sizeof(tkp),0);if (OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken)) thenbegintkp.PrivilegeCount:=1;tkp.P 阅读全文
posted @ 2008-09-10 17:41 孤独的猫 阅读(211) 评论(0) 推荐(0) 编辑

摘要: 摘自盒子http://www.2ccc.com有任何疑问请到 http://yaoqiaofeng.blog.163.com 留言给我,由于本程序是以BDS2006编译的,所以BDS2006以前的版本打开时会提示属性错误,但没有关系,直接点击忽略即可,不会影响程序function EnableDebugPriv: Boolean;varhToken: THandle;tp: TTokenPrivileges;rl: Cardinal;beginResult := false;//打开进程令牌环OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_ 阅读全文
posted @ 2008-09-10 17:40 孤独的猫 阅读(373) 评论(0) 推荐(0) 编辑

摘要: 首先下载audio-player插件,并解压到wordpress根目录下的wp-content\plugins下,并启用此插件,并在根目录下创建audio子目录,撰写如下文章即可在博客中听音乐了:音乐[audio:1.mp3,2.mp3,3.mp3] 阅读全文
posted @ 2008-09-10 17:36 孤独的猫 阅读(172) 评论(0) 推荐(0) 编辑

摘要: Wordpress是一种用PHP语言和MySQL的数据库的开源的免费Blog引擎,用户可以在支持PHP和MySQL数据库的服务器上建立自己的Blog,它具有非常强大的功能和成千上万的插件和模板主题。安装步骤如下(本文以Wordpress2.6中文版为例):(1) 在MySQL中创建Wordpress库,并授予Wordpress用户此库的权限mysql: create database wordpress;mysql: GRANT ALL ON wordpress.* TO wordpress@localhost IDENTIFIED BY "19761217"(2) 在wo 阅读全文
posted @ 2008-09-10 17:33 孤独的猫 阅读(279) 评论(0) 推荐(0) 编辑

摘要: 下载主题(Theme)wordpress的主题是由一系列的模板文件组成,通常包括一个CSS样式文件,至少一个PHP代码,可能还有一些图片文件。更换主题时,只需将下载的文件解压到wordpress安装目录下的wp-content/themes/目录内,即可在管理后台看到新上传的主题,会有一张缩略图,只需单击这张缩列图就可以激活这个主题插件使用(Plugin)同主题一样,插件也只需解压到安装目录的wp-content/plugins/下,即可在后台管理页面的插件管理中看到,然后激活就可以使用下载插件了。 阅读全文
posted @ 2008-09-10 17:32 孤独的猫 阅读(286) 评论(0) 推荐(0) 编辑

摘要: WordPress数据备份方案从 2008年8月26日 开始被阅读 189 次 在使用WordPress的过程中,总会当心自己的数据也许什么时候会丢失,这里也许可能是虚拟主机提供商的问题,也可能自己误操作的问题,也可能自己管理的服务器出现的问题。总之,WordPress数据备份的问题不能不考虑。这里,将通过介绍多种方法来说明如何在虚拟主机和自己有管理权限的服务器上有效的备份自己的博客文章数据。首先当然要说明一下,你的博客程序是使用WordPress来创建的,否则下面说的可能大多数对你无效。1. 使用插件进行备份我想这个是大多数WordPress用户经常使用的方法,当然需要在这里首先介绍。个人感 阅读全文
posted @ 2008-09-10 17:30 孤独的猫 阅读(218) 评论(0) 推荐(0) 编辑

摘要: charindex函数返回字符或字符串在另一个字符串中的起始位置。charindex函数调用方法如下:charindex ( expression1 , expression2 [ , start_location ] )expression1是要到expression2中寻找的字符中,start_location是charindex函数开始在expression2中找expression1的位置。charindex函数返回一个整数,返回的整数是要找的字符串在被找的字符串中的位置。假如charindex没有找到要找的字符串,那么函数整数“0”。让我们看看下面的函数命令执行的结果:charind 阅读全文
posted @ 2008-09-10 15:34 孤独的猫 阅读(322) 评论(0) 推荐(0) 编辑

摘要: Access对应SQL Server的SubString函数为midAccess对应SQL Server的patindex函数为instr 阅读全文
posted @ 2008-09-10 15:33 孤独的猫 阅读(232) 评论(0) 推荐(0) 编辑

摘要: # Sample code from Programing Ruby, page 239require 'soap/wsdlDriver'以下通过对Google的服务请求,使用Google的一个服务,并使用了WSDL(Web Services Description Language)来完成.(前提是你拥有一个Google Web API的使用账号,并保存在主目录的.goolge_key文件中)require 'cgi'WSDL_URL = "http://api.google.com/GoogleSearch.wsdl"soap = SOA 阅读全文
posted @ 2008-09-10 15:23 孤独的猫 阅读(166) 评论(0) 推荐(0) 编辑

摘要: 我们可以通过SOAP服务器来访问预先定义好的对象,通过soap/rpc/driver就可做到,这也可以看作是同其他语言交互的一种很好的方式,服务器端存为server.rbrequire 'soap/rpc/standaloneServer'class InterestCalculator attr_reader :call_count def initialize @call_count=0 end def compound(printcipal,rate,freq,years) @call_count+=1 printcipal*(1.0+rate/freq)**(freq* 阅读全文
posted @ 2008-09-10 15:15 孤独的猫 阅读(235) 评论(0) 推荐(0) 编辑

摘要: (1) Execute方法$irb>> exec 'echo "hello $HOMENAME"'(2) System方法>>system 'echo "hello $HOMENAME"'(3) 反引号>> today= `date`(4) open3#popen3>>stdin,stdout,stderr=open3.popen3('dc')(5) IO#popen>>IO.popen("date") {|f| puts f. 阅读全文
posted @ 2008-09-10 15:12 孤独的猫 阅读(446) 评论(0) 推荐(0) 编辑

摘要: irb是从命令行运行的交互式shell在命令行中输入irb后回车,进入交互式ruby模式(1) 可以用load载入rb文件执行,如以下文件code/fib_up_to.rbdef fib_up_to(max)i1,i2=1,1while i1<=maxyield i1i1,i2=i2,i1+i2endend%irbirb(main):001:0>load 'code/fib_up_to.rb'=>trueirb(main):002:0>result=[]=>[]irb(main):003:0>fib_up_to(20){|var| resul 阅读全文
posted @ 2008-09-10 15:11 孤独的猫 阅读(424) 评论(0) 推荐(0) 编辑

摘要: 1.要求安装ruby1.8.3以上,并且需要安装rails,版本也要匹配好,否则会出错。(下文用typo4.1和rails1.2.3安装成功)2.下载并安装typo,gem install typo -v"=4.1"3.升级rake,gem update rake4.安装mongrel,gem install mongrel5.进入mysql,建库和表mysql -uroot -p'你的密码'mysql>create database typo;mysql>GRANT ALL ON typo.* to typo@localhost IDENTIF 阅读全文
posted @ 2008-09-10 15:04 孤独的猫 阅读(277) 评论(0) 推荐(0) 编辑

摘要: # Sample code from Programing Ruby, page 250require 'tk'class GifViewer def initialize(filelist) setup_viewer(filelist) end def run Tk.mainloop end def setup_viewer(filelist) @root = TkRoot.new {title 'Scroll List'} frame = TkFrame.new(@root) image_w = TkPhotoImage.new TkLabel.new(fr 阅读全文
posted @ 2008-09-10 15:02 孤独的猫 阅读(504) 评论(0) 推荐(0) 编辑

摘要: # # To change this template, choose Tools | Templates# and open the template in the editor.# Sample code from Programing Ruby, page 248require 'tk'class Draw def do_press(x, y) @start_x = x @start_y = y @current_line = TkcLine.new(@canvas, x, y, x, y) end def do_motion(x, y) if @current_line 阅读全文
posted @ 2008-09-10 14:56 孤独的猫 阅读(440) 评论(0) 推荐(0) 编辑

上一页 1 ··· 22 23 24 25 26