����ipc����
| 2 | |
| 3 | // ����ipc���� |
| 4 | int WNetApi::WNetAddConnection2Api(LPWSTR lpRemoteName, LPWSTR lpDomainUserName, LPWSTR lpPassword) |
| 5 | { |
| 6 | // wprintf(L"net use %s /u:%s %s\n", lpRemoteName, lpDomainUserName, lpPassword); |
| 7 | DWORD dwRetVal; |
| 8 | NETRESOURCE nr; |
| 9 | DWORD dwFlags; |
| 10 | |
| 11 | memset(&nr, 0, sizeof(NETRESOURCE)); // ��սṹ��������ڴ� |
| 12 | |
| 13 | |
| 14 | // ���ṹ�������ֵ |
| 15 | nr.dwType = RESOURCETYPE_ANY; |
| 16 | nr.lpLocalName = NULL; // F: ӳ�䵽���صĴ��̣����磺Z�̵�. ����ַ���Ϊ�գ�����lpLocalNameΪNULL����ú�����������������Դ�����ӣ��������ض����豸 |
| 17 | nr.lpRemoteName = lpRemoteName; // \\192.168.232.128\temp Ŀ��������Ź����Ĵ��� |
| 18 | nr.lpProvider = NULL; |
| 19 | |
| 20 | |
| 21 | dwFlags = CONNECT_UPDATE_PROFILE; |
| 22 | dwRetVal = WNetAddConnection2(&nr, lpPassword, lpDomainUserName, dwFlags); |
| 23 | |
| 24 | // �ж��Ƿ�ɹ��������� |
| 25 | if (dwRetVal == NO_ERROR) |
| 26 | { |
| 27 | // wprintf(L"[+] %s Connection success\n", nr.lpRemoteName); |
| 28 | return 1; |
| 29 | } |
| 30 | else if (dwRetVal == 67) // ����δ�ҵ� |
| 31 | { |
| 32 | // wprintf(L"[-] %s The network name could not be found.\n", nr.lpRemoteName); |
| 33 | return 0; |
| 34 | } |
| 35 | else if (dwRetVal == 1326) // �˺�������� |
| 36 | { |
| 37 | // wprintf(L"[-] %s The user name or password is incorrect.\n", nr.lpRemoteName); |
| 38 | return 0; |
| 39 | } |
| 40 | else // �������� |
| 41 | { |
| 42 | // wprintf(L"[-] %s WNetAddConnection2 failed with error: %u\n", nr.lpRemoteName, dwRetVal); |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | } |
| 47 | |
| 48 | // ɾ��ipc���� |
| 49 | int WNetApi::WNetCancelConnection2Api(LPWSTR lpRemoteName) |