void process_session(SESSION_INFO_1 s_info) { LPFILE_INFO_3 f_info = NULL; DWORD ent_read = 0, ent_total = 0, res_handle = 0; NET_API_STATUS res = NERR_Success; if ((res = NetFileEnum(NULL, NULL, s_info.sesi1_username, 3, (LPBYTE *)&f_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, (PDWORD_PTR)&res_handle)) == NERR_Success || res == ERROR_MORE_DATA) { for(unsigned i=0; i < ent_read; i++) process_file(s_info, f_info[ i ]); NetApiBufferFree(f_info); } else printError(res); }
std::vector<flock> getSharedFiles(const std::wstring& path){ FILE_INFO_3* pFiles = NULL; DWORD nRead = 0, nTotal = 0; std::vector<flock> ret; std::vector<long> ids; int res = ERROR_MORE_DATA; std::vector<wchar_t> writable(path.begin(), path.end()); writable.push_back('\0'); int totalDone = 0; while(res==ERROR_MORE_DATA){ try{ res = NetFileEnum( NULL, // servername, NULL means localhost &writable[0], // basepath, directory where VB6 program is NULL, // username, searches for all users 3, // level, we just need resource ID (BYTE**)&pFiles, // bufptr, MAX_PREFERRED_LENGTH, // prefmaxlen, collect as much as possible &nRead, // entriesread, number of entries stored in pFiles &nTotal, // totalentries, ignore this NULL //resume_handle, ignore this ); } catch(int exx){ printf("%i",exx); break; } for (unsigned int i=0; i < nRead; ++i){ //int nret = NetFileClose(NULL, pFiles[i].fi2_id); flock tmp(pFiles[i]); ret.push_back(tmp); } NetApiBufferFree(pFiles); } return ret; }