1 |
// Stay Connectified |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include <windows.h> |
8 |
#include <shellapi.h> |
9 |
#include <ras.h> |
10 |
#include <raserror.h> |
11 |
|
12 |
#pragma warning(disable: 4267) |
13 |
|
14 |
struct Exception |
15 |
{ |
16 |
unsigned long code; |
17 |
Exception(unsigned long code) : code(code) {} |
18 |
}; |
19 |
|
20 |
template <typename Type> |
21 |
Type check(Type code) |
22 |
{ |
23 |
if (code != 0) |
24 |
throw Exception(code); |
25 |
|
26 |
return code; |
27 |
} |
28 |
|
29 |
int main(int argc, char** argv) |
30 |
{ |
31 |
RASDIALPARAMS params = { sizeof (RASDIALPARAMS), L"NETHOME Intranet VPN" }; |
32 |
int password; |
33 |
|
34 |
check(RasGetEntryDialParams(NULL, ¶ms, &password)); |
35 |
|
36 |
HRASCONN connection(NULL); |
37 |
|
38 |
check(RasDial(NULL, NULL, ¶ms, -1, NULL, &connection)); |
39 |
|
40 |
return 0; |
41 |
} |