ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/StayConnectified/StayConnectified.cpp
Revision: 446
Committed: 2005-05-14T04:06:03-07:00 (20 years, 1 month ago) by douglas
File size: 1237 byte(s)
Log Message:
Meep!

File Contents

# Content
1 // Stay Connectified
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #include <iostream>
8 #include <string>
9 #include <vector>
10
11 #include <windows.h>
12 #include <shellapi.h>
13 #include <ras.h>
14 #include <raserror.h>
15
16 #pragma warning(disable: 4267)
17
18 struct Exception
19 {
20 unsigned long code;
21 Exception(unsigned long code) : code(code) {}
22 };
23
24 template <typename Type>
25 Type check(Type code)
26 {
27 if (code != 0)
28 throw Exception(code);
29
30 return code;
31 }
32
33 int main(int argc, char** argv)
34 {
35 for (int index(1); index != argc; ++index)
36 std::wcerr << argv[index] << std::endl;
37
38 std::vector<RASENTRYNAME> entries(1);
39
40 entries.front().dwSize = sizeof (RASENTRYNAME);
41
42 unsigned long size(entries.size() * sizeof (RASENTRYNAME)), count;
43
44 loop: try
45 {
46 check(RasEnumEntries(NULL, NULL, &entries.front(), &size, &count));
47 }
48 catch (const Exception& exception)
49 {
50 if (exception.code == ERROR_BUFFER_TOO_SMALL)
51 {
52 entries.resize(entries.size() + size / sizeof (RASENTRYNAME));
53
54 size = entries.size() * sizeof (RASENTRYNAME);
55
56 goto loop;
57 }
58 else
59 throw exception;
60 }
61
62 entries.resize(count);
63
64 for (std::vector<RASENTRYNAME>::iterator entry(entries.begin()); entry != entries.end(); ++entry)
65 std::wcout << entry->szEntryName << std::endl;
66
67 return 0;
68 }

Properties

Name Value
svn:eol-style native
svn:keywords Id