Connect to another pc using delphi

HI,

  I want to connect to a system which is in lan. i will supply username and password required also. i want to download the files from that machine to my machine. Can any body gives Delphi code snippet to do this.
sbondalapatiAsked:
Who is Participating?
 
cyberkiwiCommented:
This first link will show you how to perform authentication in Delphi
http://koti.mbnet.fi/akini/delphi/ntlmlogin/

The second one will show you how to copy a file now that you have authenticated
http://www.efg2.com/Lab/Library/UseNet/2001/1028.txt

In actual fact, I would try #2 first and see if Windows be default shows the login prompt
0
 
sbondalapatiAuthor Commented:
I tried second solution. But its not connecting directly. First one is too complicated.
0
 
cyberkiwiCommented:
It may be easier just to map the drive then Delphi can just use the mapped drive letter. Is that possible?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
sbondalapatiAuthor Commented:
I required the code snippet in delphi, which will have all the windows authentications handled correctly.
0
 
cyberkiwiCommented:
That's where you do need the code from the first link - it is no easy feat to authenticate to AD
0
 
Mahdi78Commented:
Try INDY FTP Client/Server demo
0
 
sbondalapatiAuthor Commented:
is FTP Client/Server will work for lan?
0
 
Mahdi78Commented:
Yeah FTP Client/Server work for LAN, you need to use and set private IP of your local Network
0
 
malsoftCommented:
Copying files to/from a Windows server is relatively simple if you use the drive mapping option. This also is simple to do if you use the CreateProcess API and call up "net use" with the appropriate username, password and mapping details. I've been using that method to move files around in a service-based process for several months without any problems.
0
 
Mahdi78Commented:
Try Filezilla Client and Server
http://filezilla-project.org/
0
 
systanCommented:
Here's my code: (just add 1Listbox)

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
    procedure ListBox1DblClick(Sender: TObject);
  private
    { Private declarations }
    Procedure SharedFolderDrive();
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses ShellApi;

{$R *.dfm}

procedure EnumRemoteDrives(Items: TStringlist);
function EnumerateFunc(lpnr: PNetResource; Items: TStringList; DrillDepth: Integer): Boolean;
var
lpnrLocal: PNetResource;
hEnum:THandle;
dwResult, dwResultEnum, cbBuffer, cEntries: DWORD;
i: Integer;
p1:PChar;
p2:PnetResource;
s, t: string;
begin
dwResult := WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_DISK, 0, lpnr, hEnum);
if dwResult <> NO_ERROR then begin EnumerateFunc := False;
exit;
end;
cbBuffer := 32768;
cEntries := $FFFFFFFF;
lpnrLocal := PNetResource(GlobalAlloc(GPTR,cbBuffer));
repeat
dwResultEnum := WNetEnumResource(hEnum,cEntries, lpnrLocal, cbBuffer);
if dwResultEnum = NO_ERROR then begin
for i := 0 to cEntries - 1 do begin
p1 := PChar(lpnrLocal) + i *
SizeOf(TNetResource);
p2 := PNetResource(p1);
s := StrPas(p2^.lpRemoteName);
if Length(s) > 2 then
if (s[1] = '\') and
(s[2] = '\') then begin
t := Copy(s,
3, Length(s) - 2);
if Pos('\', t)
<> 0 then
items.Add(s);
end;
if (p2.dwUsage and RESOURCEUSAGE_CONTAINER) = RESOURCEUSAGE_CONTAINER then
if DrillDepth < 3 then
EnumerateFunc(p2, Items, DrillDepth + 1);
end;
end;
until dwResultEnum = ERROR_NO_MORE_ITEMS;
GlobalFree(HGLOBAL(lpnrLocal));
dwResult := WNetCloseEnum(hEnum);
if dwResult <> NO_ERROR then begin EnumerateFunc := False;
 exit;
  end;
EnumerateFunc := True;
end;
begin
EnumerateFunc(nil, Items, 0);
end;

Procedure Tform1.SharedFolderDrive();
var
netx: string;
i: byte;
sl : tstringlist;
begin
sl := tstringlist.create;
EnumRemoteDrives(sl);
for i:= 0 to sl.Count-1 do
begin
netx:=sl[i];
listbox1.items.add(netx);
end;
sl.free;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
SharedFolderDrive;
end;

procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
ShellExecute(Handle,'open', Pchar(listbox1.items[listbox1.itemINdex]), nil, nil, SW_SHOWNORMAL) ;
end;

end.
0
 
sbondalapatiAuthor Commented:
HI all

 thanks for the solutions.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.