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;
}