 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Michael Gillen Guest
|
Posted: Mon Jan 30, 2006 1:47 pm Post subject: Re: Mapping a network drive on Windows and Linux |
|
|
Bono wrote:
| Quote: | I'm writing a CLX (multiplatform) Application and I need to connect to a
remote network
machine (I know the IP address).
Does anybody know how can I map a network drive? Is it going to work on both
(windows and linux) platforms?
|
This snippet of code works mapping to a network drive - Windows or Samba.
// We can map via IP address or system name
if(CbxUseIP->Checked)
RemoteName = "\\"+EdtIpAddress->Text+AnsiString(ShareName);
else
RemoteName = "\\"+EdtComputerName->Text+AnsiString(ShareName);
// An avilable drive letter was selected
AnsiString DriveName = CbxAvailDrives->Text.c_str();
NETRESOURCE nr;
DWORD dwFlags;
ZeroMemory(&nr, sizeof(nr));
nr.dwType = RESOURCETYPE_DISK;
nr.lpLocalName = DriveName.c_str();
nr.lpRemoteName = RemoteName.c_str();
dwFlags = NULL;
if(CbxRemember->Checked)
dwFlags = dwFlags | CONNECT_UPDATE_PROFILE;
Screen->Cursor = crHourGlass;
int rc;
rc = WNetAddConnection2(&nr,EdtPasswd->Text.c_str(), EdtUserName->Text.c_str(), dwFlags);
Screen->Cursor = crDefault;
if(rc != NO_ERROR)
{
// A special message for this
if(rc == ERROR_BAD_NETPATH)
MessageDlg("The network path cannot be found.", mtError, TMsgDlgButtons() << mbOK, 0);
else
GetLastErrorStr( rc );
return false;
}
--
-Michael Gillen
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|