Jump to content

kopernikus

Members
  • Content Count

    2
  • Joined

  • Last visited

Everything posted by kopernikus

  1. kopernikus

    How to read file on plugged in Android device

    Update: procedure TMainForm.bbCopyClick(Sender: TObject); var i,n,j : integer; fileOp : IFileOperation; siSrcList : IShellItemArray; idList : array of PItemIDList; siSrcFile,siDestFolder : IShellItem; begin with ShellListView do if assigned(Selected) then begin n:=Selected.Index; OleCheck(CoCreateInstance(CLSID_FileOperation,nil,CLSCTX_ALL,IFileOperation,fileOp)); if SelCount=1 then with SelectedFolder do begin OleCheck(SHCreateItemFromIDList(AbsoluteID,IShellItem,siSrcFile)); OleCheck(SHCreateItemFromParsingName(PChar(edDestDir.Text),nil,IShellItem,siDestFolder)); OleCheck(fileOp.CopyItem(siSrcFile,siDestFolder,pchar(DisplayName),nil)); OleCheck(fileOp.PerformOperations); end else begin SetLength(idList,SelCount); j:=0; OleCheck(fileOp.SetOperationFlags(FOF_FILESONLY+FOF_NOCONFIRMMKDIR+FOF_NO_CONNECTED_ELEMENTS)); for i:=n to Items.Count-1 do if Items[i].Selected then begin idList[j]:=Folders[i].AbsoluteID; inc(j); end; OleCheck(SHCreateShellItemArrayFromIDLists(SelCount,@idList[0],siSrcList)); OleCheck(SHCreateItemFromParsingName(PChar(edDestDir.Text),nil,IShellItem,siDestFolder)); OleCheck(fileOp.CopyItems(siSrcList,siDestFolder)); OleCheck(fileOp.PerformOperations); idList:=nil; end; end; end;
  2. kopernikus

    How to read file on plugged in Android device

    The components from Vcl.Shell.ShellCtrls.pas and this code snippet will do the job: procedure TMainForm.bbCopyClick(Sender: TObject); var i,n,j : integer; fileOp : IFileOperation; siSrcList : IShellItemArray; idList : array of PItemIDList; siSrcFile,siDestFolder : IShellItem; begin with ShellListView do if assigned(Selected) then begin n:=Selected.Index; if SelCount=1 then with SelectedFolder do begin OleCheck(SHCreateItemFromIDList(AbsoluteID,IShellItem,siSrcFile)); OleCheck(SHCreateItemFromParsingName(PChar(edDestDir.Text),nil,IShellItem,siDestFolder)); OleCheck(fileOp.CopyItem(siSrcFile,siDestFolder,pchar(DisplayName),nil)); OleCheck(fileOp.PerformOperations); end else begin SetLength(idList,SelCount); j:=0; OleCheck(CoCreateInstance(CLSID_FileOperation,nil,CLSCTX_ALL,IFileOperation,fileOp)); OleCheck(fileOp.SetOperationFlags(FOF_FILESONLY+FOF_NOCONFIRMMKDIR+FOF_NO_CONNECTED_ELEMENTS)); for i:=n to Items.Count-1 do if Items[i].Selected then begin idList[j]:=Folders[i].AbsoluteID; inc(j); end; OleCheck(SHCreateShellItemArrayFromIDLists(SelCount,@idList[0],siSrcList)); OleCheck(SHCreateItemFromParsingName(PChar(edDestDir.Text),nil,IShellItem,siDestFolder)); OleCheck(fileOp.CopyItems(siSrcList,siDestFolder)); OleCheck(fileOp.PerformOperations); idList:=nil; end; end; end;
×