exeexe吧 关注:1贴子:209
  • 4回复贴,共1

一些函数

收藏回复

  • 220.160.64.*
function gettxt(ffile: string): string;
var
  hFile: DWORD;
  iSize: DWORD;
begin
  hFile := CreateFile(PChar(ffile), GENERIC_READ, 3, nil,
    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  iSize := GetFileSize(hFile, nil);
  SetLength(Result, iSize+1);
  ReadFile(hFile, Result[1], iSize, iSize, nil);
  CloseHandle(hFile);
  Result := string(PChar(Result));
end;

function settxt(ffile, str: string): string;
var f:textfile;
begin
//
   assignfile(f,ffile);
   rewrite(f);
   write(f,str);
   closefile(f);
end;



1楼2005-02-20 17:57回复
    • 220.160.64.*
    function mi(str: string): string;
    var s:string;i:integer;
    begin
     s:=str;
     for i := 1 to length(s) do
     begin
     s[i]:=chr(ord(s[i]) xor 52);
     end;
     result:=s;
    end;
     function gotoWWW(str: string): string;
     begin
     shellapi.ShellExecute(0,'open',pchar(str),'','',1)
     end;
    end.


    2楼2005-02-20 17:57
    回复
      • 220.160.64.*
      function gettxtm(ffile: string): string;
       var
       hFile: DWORD;
       iSize: DWORD; i:integer;
      begin
       hFile := CreateFile(PChar(ffile), GENERIC_READ, 3, nil,
       OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
       iSize := GetFileSize(hFile, nil);
       SetLength(Result, iSize+1);
       ReadFile(hFile, Result[1], iSize, iSize, nil);
       CloseHandle(hFile); 
       for i:=1 to length(Result) do
       begin
       Result[i]:=chr(ord(Result[i]) xor 52);
       end;
      end;


      3楼2005-02-20 17:57
      回复
        • 220.160.67.*
        function StrReplace(S, old, new: string; m: boolean = true): string;
        var I: Integer; rs: string;
        begin
         I := 0;
         repeat
         begin
         I := I + 1;
         if copy(S, I, length(old)) = old then begin
         rs := rs + new;
         if m then
         I := I + length(old) - 1
         else begin
         rs := rs + copy(S, length(rs) + 1, length(S) - length(rs));
         result := rs;
         exit;
         end;
         end
         else begin
         rs := rs + S[I];
         end;

         end;
         until I >= length(S);
         result := rs;

        end;


        5楼2005-03-14 19:58
        回复
          • 222.76.39.*
          uses windows,sysutils,shellapi,activex ,ShlObj,Forms ;






          function SelectDirectory(const Caption: string; const Root: WideString;
           var Directory: string): Boolean;
          var
           WindowList: Pointer;
           BrowseInfo: TBrowseInfo;
           Buffer: PChar;
           RootItemIDList, ItemIDList: PItemIDList;
           ShellMalloc: IMalloc;
           IDesktopFolder: IShellFolder;
           Eaten, Flags: LongWord;
          begin
           Result := False;
           if not DirectoryExists(Directory) then
           Directory := '';
           FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
           if (ShGetMalloc(ShellMalloc) = S_OK) and (ShellMalloc <> nil) then
           begin
           Buffer := ShellMalloc.Alloc(MAX_PATH);
           try
           RootItemIDList := nil;
           if Root <> '' then
           begin
           SHGetDesktopFolder(IDesktopFolder);
           IDesktopFolder.ParseDisplayName(application.Handle, nil,
           POleStr(Root), Eaten, RootItemIDList, Flags);
           end;

           with BrowseInfo do
           begin
           hwndOwner := Application.Handle;
           pidlRoot := RootItemIDList;
           pszDisplayName := Buffer;
           lpszTitle := PChar(Caption);
           ulFlags := BIF_RETURNONLYFSDIRS;
           if Directory <> '' then
           begin
           lpfn := SelectDirCB;
           lParam := Integer(PChar(Directory));
           end;
           end;
           WindowList := DisableTaskWindows(0);
           try
           ItemIDList := ShBrowseForFolder(BrowseInfo);
           finally
           EnableTaskWindows(WindowList);
           end;
           Result := ItemIDList <> nil;
           if Result then
           begin
           ShGetPathFromIDList(ItemIDList, Buffer);
           ShellMalloc.Free(ItemIDList);
           Directory := Buffer;
           end;
           finally
           ShellMalloc.Free(Buffer);
           end;
           end;
          end;


          6楼2005-03-20 17:04
          回复