Я вызываю WNetAddConnection2 много раз без WNetCancelConnection2, я просто проверяю его возвращаемое значение. Это работает в Windows Server 2003, только создать одно соединение, но в Windows Server 2008, он создал слишком много соединений. В чем проблема?
РЕДАКТИРОВАТЬ - код в соответствии с комментарием:
TCHAR szLocalName[32] = _T("t:"), szRemoteName[MAX_PATH] = _T("\\\\ws2008_1\\sample_share");
// Assign our values to the NETRESOURCE structure.
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = szLocalName;
nr.lpRemoteName = szRemoteName;
nr.lpProvider = NULL;
// Call the WNetAddConnection2 function to assign
// a drive letter to the share.
dwRetVal = WNetAddConnection2(&nr, 0, 0, FALSE);
Вывод:
mount <x:> to <\\ws2008_1\sample_share_2> with :0 PID:8956
mount <x:> to <\\ws2008_1\sample_share_2> with :0 PID:7284
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:8592
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:4196
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:7708
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:7028
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:3988
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:3680
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:6364
remote name is <\\ws2008_1\sample_share_2> and errCode is: 85 PID:7764
mount <x:> to <\\ws2008_1\sample_share_2> with :0 PID:8764
mount <x:> to <\\ws2008_1\sample_share_2> with :0 PID:4692
mount <x:> to <\\ws2008_1\sample_share_2> with :0 PID:4996
mount <x:> to <\\ws2008_1\sample_share_2> with :0 PID:5300
mount <x:> to <\\ws2008_1\sample_share_2> with :0 PID:6028
Примечание: процесс был создан CreateProcessAsUser, имя пользователя совпадает. Из сообщения журнала иногда работает, связан ли сеанс входа в систему?
Спасибо
Dma