//////这样是成功的
nts.lpProvider   = NULL;
nts.dwType=RESOURCETYPE_DISK;
nts.dwDisplayType=RESOURCEDISPLAYTYPE_SHARE;
nts.lpLocalName= _T("Z:");
nts.lpRemoteName=_T("\\\\192.168.40.156\\report");
dwResult=WNetAddConnection2(&nts,lpPassword,lpUserName,0);但这样不成功:
char Local_Drv[100];
char Remote_Share[100];
         nts.lpProvider   = NULL;
nts.dwType=RESOURCETYPE_DISK;
nts.dwDisplayType=RESOURCEDISPLAYTYPE_SHARE; GetPrivateProfileString("TransferFile",/////这个函数调用是成功的,读一个.ini文件里的信息
"Local_Drv",
"KK",
Local_Drv,
1000,
"D:\\transfiles\\Transfer\\TransferFile.ini"); GetPrivateProfileString("TransferFile",/////同上 
"Remote_Share",
"KK",
Remote_Share,
1000,
"D:\\transfiles\\Transfer\\TransferFile.ini");
nts.lpLocalName =new char[100];
nts.lpRemoteName=new char[100]; strcpy(nts.lpLocalName,Local_Drv);
strcpy(nts.lpRemoteName,Remote_Share);////这里都还是成功的,因为用
////cout<<nts.lpLocalName<<endl<<nts.lpRemoteName<<endl;打印出的就是.ini文件里的信息。
         dwResult=WNetAddConnection2(&nts,lpPassword,lpUserName,0);///返回值为67
因为dwResult要为0才正确,请问,我哪里错了?我估计是nts.lpLocalName =new char[100];
nts.lpRemoteName=new char[100];两句。
但没法子,GetPrivateProfileString返回的值Local_Drv、Remote_Share不能直接strcpy给nts.lpLocalName 、 nts.lpRemoteName
如何解决?