🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4408

Re: Mapping a network drive on Windows and Linux

#4408
From: Bono
Date: Mon, 06 Feb 2006 08:56
59 lines
2840 bytes
The snippet is working pretty fine on my Windows machine.

But WNetAddConnection2(...) is a Windows API function. I'm sure I'll not be
able to compile this code on a Linux machine.
Can anybody help me?

Thanks!!
Andrea



"Michael Gillen" <michael@gillenconsultinggroup-nospam.com> ha scritto nel
messaggio news:43de271f@newsgroups.borland.com...
> Bono wrote:
>
> > 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
Technical Details
Message-ID: <43e70d7a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!binfeed1.tudelft.nl!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43dded9d$1@newsgroups.borland.com> <43de271f@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d7567c071b7d994a
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Bono" <bono@ingv.it>
From: "Bono" <bono@ingv.it>
Newsgroups: borland.public.cppbuilder.nativeapi
References:  <43dded9d$1@newsgroups.borland.com> <43de271f@newsgroups.borland.com>
Subject: Re: Mapping a network drive on Windows and Linux
Date: Mon, 6 Feb 2006 09:56:46 +0100
Lines: 61
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
NNTP-Posting-Host: 193.206.122.237
Message-ID: <43e70d7a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1139215738 193.206.122.237 (6 Feb 2006 00:48:58 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!binfeed1.tudelft.nl!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail