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;
}
Re: how to use map a network drive?
See WNetAddConnection2
Rating isn't important...But gurus respect it and keep high
!!!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...
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.