1 |
douglas |
446 |
// 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 |
douglas |
447 |
RASDIALPARAMS params = { sizeof (RASDIALPARAMS), L"NETHOME Intranet VPN" }; |
32 |
|
|
int password; |
33 |
douglas |
446 |
|
34 |
douglas |
447 |
check(RasGetEntryDialParams(NULL, ¶ms, &password)); |
35 |
douglas |
446 |
|
36 |
douglas |
447 |
HRASCONN connection(NULL); |
37 |
douglas |
446 |
|
38 |
douglas |
447 |
check(RasDial(NULL, NULL, ¶ms, -1, NULL, &connection)); |
39 |
douglas |
446 |
|
40 |
|
|
return 0; |
41 |
|
|
} |