In the program, the password of the write authority is known. -------------------------------------------------- ------------- 1 use DWORD WNetAddConnection2 (lPNETRESOURCE lpNetResource, // connection details LPCTSTR lpPassword, // password LPCTSTR lpUsername, // user name DWORD dwFlags // connection options); establishing connection IPC 2 Use int ShfileOperation (lpshfileopstruct lpfileop);
Example:
#define movpath "//192.168.0.177"#define rmpath" //192.168.0.178"#define user "root" #define pwd "123456"
NetResource NS; MEMSET (& NS, 0, SIZEOF (NS)); ns.dwtype = resourcetype_any; ns.lplocalname = "z:"; ns.lpremotename = (char *) (lpctstr) MovPath; WnetaddConnection2 (& ns, (lpctstr) PWD, (LPCTSTR) User, Connect_Update_profile;
To join this library file ^ _ ^ # Pragma Comment (lib, "mpr.lib");