// Stay Connectified // // Douglas Thrift // // $Id$ #include #include #include #include #include #include #include #pragma warning(disable: 4267) struct Exception { unsigned long code; Exception(unsigned long code) : code(code) {} }; template Type check(Type code) { if (code != 0) throw Exception(code); return code; } int main(int argc, char** argv) { for (int index(1); index != argc; ++index) std::wcerr << argv[index] << std::endl; std::vector entries(1); entries.front().dwSize = sizeof (RASENTRYNAME); unsigned long size(entries.size() * sizeof (RASENTRYNAME)), count; loop: try { check(RasEnumEntries(NULL, NULL, &entries.front(), &size, &count)); } catch (const Exception& exception) { if (exception.code == ERROR_BUFFER_TOO_SMALL) { entries.resize(entries.size() + size / sizeof (RASENTRYNAME)); size = entries.size() * sizeof (RASENTRYNAME); goto loop; } else throw exception; } entries.resize(count); for (std::vector::iterator entry(entries.begin()); entry != entries.end(); ++entry) std::wcout << entry->szEntryName << std::endl; return 0; }