请指教一下delphy 里面的fileopen的具体用法。

解决方案 »

  1.   

    function FileOpen(const FileName: string; Mode: LongWord): Integer;
    {$IFDEF MSWINDOWS}
    const
      AccessMode: array[0..2] of LongWord = (
        GENERIC_READ,
        GENERIC_WRITE,
        GENERIC_READ or GENERIC_WRITE);
      ShareMode: array[0..4] of LongWord = (
        0,
        0,
        FILE_SHARE_READ,
        FILE_SHARE_WRITE,
        FILE_SHARE_READ or FILE_SHARE_WRITE);
    begin
      Result := -1;
      if ((Mode and 3) <= fmOpenReadWrite) and
        ((Mode and $F0) <= fmShareDenyNone) then
        Result := Integer(CreateFile(PChar(FileName), AccessMode[Mode and 3],
          ShareMode[(Mode and $F0) shr 4], nil, OPEN_EXISTING,
          FILE_ATTRIBUTE_NORMAL, 0));
    end;// 最后还是调用API函数CreateTile的
      

  2.   

    我不是这个意思,我是想用fileopne读出一个文件名,再逐行读出其数据。像  .net 中
                fileopen  文件名,类型
               do while not eof(值)
                    每行的值。
                loop
      

  3.   

    FileOpen 打开文件  获得文件的句柄 然后用 
    function FileRead(Handle: Integer; var Buffer; Count: Integer): Integer;
    Handle就是这个句柄了。。一行一行的读。。不清楚DELPHI的函数 
      

  4.   

    有那位清楚吗?
    像  .net 中
                fileopen  文件名,类型
               do while not eof(值)
                    每行的值。
                loop
      

  5.   

    你用一下ReadLn看看 以前我用过这个读控制台的输入 读文件没用过
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      strLst: TStringList;
      fl: TextFile;
      s: string;
    begin
      strLst := TStringList.Create;
      AssignFile(fl, 'test.txt');
      Reset(fl);
      while not EOF(fl) do
      begin
        ReadLn(fl, s);
        strLst.Add(s);
      end;
      CloseFile(fl);
      ShowMessage(strLst.GetText);
    end;
      

  7.   

    我刚才试过用writeln替换readln,但出错呀。
      

  8.   

    var
      strLst: TStringList;
      fl: TextFile;
      s: string;
    begin
     opendialog1.Execute;
      AssignFile(fl, opendialog1.FileName);
      Reset(fl);
     while not EOF(fl) do
      begin
      writeln(fl,'china');
      end;
      CloseFile(fl);
    end;
    这样为什么会出错呢?
      

  9.   

    BOOL CMyWinApp::InitInstance()
    {
    ...
    // Parse command line for standard shell commands, DDE, file open
       CCommandLineInfo cmdInfo;
       ParseCommandLine(cmdInfo);
    // DON'T display a new MDI child window during startup!!!
       cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
    // Dispatch commands specified on the command line
       if (!ProcessShellCommand(cmdInfo))
          return FALSE;
    ...
    };
      

  10.   

    楼上的做什么把VC 还是BCB的代码拷过来?