|
-
May 4th, 2001, 03:32 PM
#1
how to use map a network drive?
Does anyone know how to programmatically map a network drive? It looks like one would use the function NetUseAdd(), but it is not working. This is what I tried:
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
USE_INFO_1 ui1;
DWORD dwParmError;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
ui1.ui1_local = _T("E:");
ui1.ui1_remote = _T("\\\\FPGHEB001NWR\\SHARED");
ui1.ui1_password = NULL;
ui1.ui1_asg_type = USE_DISKDEV;
::NetUseAdd( NULL, 1, (UCHAR*) &ui1, &dwParmError);
}
return nRetCode;
}
-
May 6th, 2001, 07:03 AM
#2
Re: how to use map a network drive?
See WNetAddConnection2
Rating isn't important...But gurus respect it and keep high
-
May 20th, 2002, 01:46 PM
#3
#include <windows.h>
#include <Winnetwk.h>
#include <iostream>
using namespace std;
void main ( void )
{
NETRESOURCE nr;
DWORD res;
TCHAR szLocalName[32] = "Q:";
TCHAR szRemoteName[MAX_PATH] = "\\\\micrle\\c$";
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = szLocalName;
nr.lpRemoteName = szRemoteName;
nr.lpProvider = NULL;
res = WNetAddConnection2(&nr, NULL, NULL, FALSE);
res = WNetCancelConnection2("Q:", CONNECT_UPDATE_PROFILE, TRUE);
return;
}
Thanks,
Todd
-
April 19th, 2004, 01:48 AM
#4
!!!Urgent!!! doubt on lpRemoteName of NETRESOUCE
Hi
#include <windows.h>
#include <Winnetwk.h>
#include <iostream>
using namespace std;
void main ( void )
{
NETRESOURCE nr;
DWORD res;
TCHAR szLocalName[32] = "Q:";
TCHAR szRemoteName[MAX_PATH] = "\\\\micrle\\c$";//doubt
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = szLocalName;
nr.lpRemoteName = szRemoteName;
nr.lpProvider = NULL;
res = WNetAddConnection2(&nr, NULL, NULL, FALSE);
res = WNetCancelConnection2("Q:", CONNECT_UPDATE_PROFILE, TRUE);
return;
}
I have a doubt in this code listing what if we dont know the (path "\\\\micrle\\c$") path and if i only know the URL.
For example if i want to map all the shared folders of say microsoft server i.e i have got only url:ftp://ftp.microsoft.com So, how can i pass the value for parameter szRemoteName.
Thank U...
-
April 19th, 2004, 11:20 AM
#5
In this case you should enumerate all shared folders and map them one by one. BTW I don't think you will succeed with ftp server
-
April 19th, 2004, 10:45 PM
#6
Can we use CFtpConnection for drive mapping???
Hi,
Can we use CFtpConnection for connecting to an FTP server and is it possible to do drive mapping with this connection?
Thank U.
-
April 20th, 2004, 10:52 AM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|