Private Declare Function File_Count Lib "p2kapi.DLL" () As Integer
Private Declare Function File_List Lib "p2kapi.DLL" (ByVal Buffer() As Byte, ByVal Count As Integer) As Integer
    Public Function GetFileList() As String        Info.FileCount = Me.File_Count()        If Info.FileCount > -1 Then
            Dim rtn As Integer
            Dim d(Info.FileCount * 512 - 1) As Byte
            Dim fileb(503) As Byte
            Dim i As Integer, s As String
            Dim j As Integer
            ReDim Info.Files(Info.FileCount - 1)            rtn = (Me.File_List(d, File_Count()))            If rtn > -1 Then
                For i = 0 To Info.FileCount - 1                    Info.Files(i).Att1 = Hex(d(i * 512 + 5)) & Hex(d(i * 512 + 6)) & Hex(d(i * 512 + 7))
                    '8-511位为文件名
                    For j = 0 To 503
                        fileb(j) = d(i * 512 + 8 + j)
                    Next
                    Info.Files(i).FileName = System.Text.Encoding.ASCII.GetString(fileb)
                Next
            End If
        Else
            Return -1
        End If

解决方案 »

  1.   

    private
        Function File_Count():Integer;external 'p2kapi.DLL';
        Function File_List(Buffer: char; Count: Integer):Integer;external 'p2kapi.DLL';
      public
         Function GetFileList():String;function TForm1.File_Count: Integer;
    var
      rtn,i,j: Integer;
      d,d1,d2,d3,fileb: integer;
      s: string;
    begin
      //info 我想应该是控件的name吧
      Info.FileCount := self.File_Count();
      d := Info.FileCount * 512 - 1;
      fileb := 503;
     //这里不知如何搞?
     // Info.Files(Info.FileCount - 1);
      rtn := (self.File_List(d, File_Count()));
      If rtn > -1 Then
      begin
        For i := 0 To Info.FileCount - 1 do
        begin
          d1 := i * 512 + 5;
          d2 := i * 512 + 7;
          d3 := i * 512 + 8 + j;
          //这里不知如何搞?
          //Info.Files(i).Att1 = Hex(d(i * 512 + 5)) & Hex(d(i * 512 + 6)) & Hex(d(i * 512 + 7))      Info.Files(i).Att1 := Hex(d1) & Hex(d2) & Hex(d3;) //8-511位为文件名
          For j := 0 To 503 do
          begin
            d := i * 512 + 8 + j;
            fileb(j) := d;
          end;
          //这里不知如何搞?
          //Info.Files(i).FileName := System.Text.Encoding.ASCII.GetString(fileb);
        end;
      end;
    end;
      

  2.   

    Info.Files(i).Att1 = Hex(d(i * 512 + 5)) & Hex(d(i * 512 + 6)) & Hex(d(i * 512 + 7))
                        '8-511位为文件名
                        For j = 0 To 503
                            fileb(j) = d(i * 512 + 8 + j)
                        Next
                        Info.Files(i).FileName = System.Text.Encoding.ASCII.GetString(fileb)应该为
    Hex 表示为IntToHex(....)
    d应该为一个函数
    fileName 是AnsiPchar