Как программно подключить сетевой
диск.
Компилятор: C++ Builder
NETRESOURCE netResource;
ZeroMemory(&netResource, sizeof(NETRESOURCE));
netResource.dwType = RESOURCETYPE_DISK;
netResource.lpLocalName = "Q:";
netResource.lpRemoteName = "\\\\SPIKE\\homedir";
if(WNetAddConnection2(&netResource, "firebird", "djf", NULL) != NO_ERROR)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsgBuf,
0,
NULL);
MessageBox(Application->Handle,
(const char *)lpMsgBuf,
"GetLastError",
MB_OK | MB_ICONINFORMATION);
LocalFree(lpMsgBuf);
}
|