Rev 71 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 71 | Rev 82 | ||
---|---|---|---|
1 | library GatewayMAC; |
1 | library GatewayMAC; |
2 | 2 | ||
3 | uses |
3 | uses |
4 | Windows, |
4 | Windows, |
5 | SysUtils, |
5 | SysUtils, |
6 | Classes, |
6 | Classes, |
7 | UD2_PluginIntf in '..\UD2_PluginIntf.pas', |
7 | UD2_PluginIntf in '..\UD2_PluginIntf.pas', |
8 | UD2_PluginUtils in '..\UD2_PluginUtils.pas', |
8 | UD2_PluginUtils in '..\UD2_PluginUtils.pas', |
9 | UD2_PluginStatus in '..\UD2_PluginStatus.pas', |
9 | UD2_PluginStatus in '..\UD2_PluginStatus.pas', |
10 | NetworkUtils in 'NetworkUtils.pas'; |
10 | NetworkUtils in 'NetworkUtils.pas'; |
11 | 11 | ||
12 | {$R *.res} |
12 | {$R *.res} |
13 | 13 | ||
14 | const |
14 | const |
15 | PLUGIN_GUID: TGUID = '{C24258AE-2092-41CA-9DB5-313B38954D01}'; |
15 | PLUGIN_GUID: TGUID = '{C24258AE-2092-41CA-9DB5-313B38954D01}'; |
16 | 16 | ||
17 | function PluginIdentifier: TGUID; cdecl; |
17 | function PluginIdentifier: TGUID; cdecl; |
18 | begin |
18 | begin |
19 | result := PLUGIN_GUID; |
19 | result := PLUGIN_GUID; |
20 | end; |
20 | end; |
21 | 21 | ||
22 | function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl; |
22 | function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl; |
23 | var |
23 | var |
24 | sl, sl2: TStringList; |
24 | sl, sl2: TStringList; |
25 | i: integer; |
25 | i: integer; |
26 | ip, mac: string; |
26 | ip, mac: string; |
27 | ec: DWORD; |
27 | ec: DWORD; |
28 | begin |
28 | begin |
- | 29 | try |
|
29 | sl := TStringList.Create; |
30 | sl := TStringList.Create; |
30 | sl2 := TStringList.Create; |
31 | sl2 := TStringList.Create; |
31 | try |
32 | try |
32 | ec := GetGatewayIPAddressList(sl); |
33 | ec := GetGatewayIPAddressList(sl); |
33 | if ec = ERROR_NOT_SUPPORTED then |
34 | if ec = ERROR_NOT_SUPPORTED then |
34 | begin |
35 | begin |
35 | result := UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED; |
36 | result := UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED; |
36 | Exit; |
37 | Exit; |
37 | end |
38 | end |
38 | else if ec <> ERROR_SUCCESS then |
39 | else if ec <> ERROR_SUCCESS then |
39 | begin |
40 | begin |
40 | result := UD2_STATUS_OSError(ec); |
41 | result := UD2_STATUS_OSError(ec); |
41 | Exit; |
42 | Exit; |
42 | end; |
43 | end; |
43 | 44 | ||
44 | for i := 0 to sl.Count-1 do |
45 | for i := 0 to sl.Count-1 do |
45 | begin |
46 | begin |
46 | ip := sl.Strings[i]; |
47 | ip := sl.Strings[i]; |
47 | ec := GetMACAddress(ip, mac); |
48 | ec := GetMACAddress(ip, mac); |
48 | if ec = ERROR_NOT_SUPPORTED then |
49 | if ec = ERROR_NOT_SUPPORTED then |
49 | begin |
50 | begin |
50 | result := UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED; |
51 | result := UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED; |
51 | Exit; |
52 | Exit; |
52 | end |
53 | end |
53 | else if (ec = S_OK) and |
54 | else if (ec = S_OK) and |
54 | (mac <> '') and |
55 | (mac <> '') and |
55 | (sl2.IndexOf(mac) = -1) then |
56 | (sl2.IndexOf(mac) = -1) then |
56 | begin |
57 | begin |
57 | sl2.add(mac); |
58 | sl2.add(mac); |
58 | end; |
59 | end; |
59 | end; |
60 | end; |
60 | result := UD2_WriteStringListToPointerW(lpIdentifier, cchSize, sl2); |
61 | result := UD2_WriteStringListToPointerW(lpIdentifier, cchSize, sl2); |
61 | finally |
62 | finally |
62 | sl.Free; |
63 | sl.Free; |
63 | sl2.Free; |
64 | sl2.Free; |
64 | end; |
65 | end; |
- | 66 | except |
|
- | 67 | on E: Exception do result := UD2_STATUS_HandleException(E); |
|
- | 68 | end; |
|
65 | end; |
69 | end; |
66 | 70 | ||
67 | function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
71 | function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
68 | var |
72 | var |
69 | stPluginName: WideString; |
73 | stPluginName: WideString; |
70 | primaryLangID: Byte; |
74 | primaryLangID: Byte; |
71 | begin |
75 | begin |
72 | primaryLangID := wLangID and $00FF; |
76 | primaryLangID := wLangID and $00FF; |
73 | if primaryLangID = LANG_GERMAN then |
77 | if primaryLangID = LANG_GERMAN then |
74 | stPluginName := 'MAC-Adressen der Gateways' |
78 | stPluginName := 'MAC-Adressen der Gateways' |
75 | else |
79 | else |
76 | stPluginName := 'Gateway MAC addresses'; |
80 | stPluginName := 'Gateway MAC addresses'; |
77 | result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName); |
81 | result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName); |
78 | end; |
82 | end; |
79 | 83 | ||
80 | function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
84 | function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
81 | begin |
85 | begin |
82 | result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft'); |
86 | result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft'); |
83 | end; |
87 | end; |
84 | 88 | ||
85 | function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
89 | function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
86 | begin |
90 | begin |
87 | result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0'); |
91 | result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0'); |
88 | end; |
92 | end; |
89 | 93 | ||
90 | function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl; |
94 | function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl; |
91 | var |
95 | var |
92 | stIdentificationMethodName: WideString; |
96 | stIdentificationMethodName: WideString; |
93 | begin |
97 | begin |
94 | stIdentificationMethodName := 'GatewayMAC'; |
98 | stIdentificationMethodName := 'GatewayMAC'; |
95 | result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName); |
99 | result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName); |
96 | end; |
100 | end; |
97 | 101 | ||
98 | function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl; |
102 | function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl; |
99 | begin |
103 | begin |
100 | result := UD2_STATUS_OK_LICENSED; |
104 | result := UD2_STATUS_OK_LICENSED; |
101 | end; |
105 | end; |
102 | 106 | ||
103 | function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl; |
107 | function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl; |
104 | begin |
108 | begin |
105 | // This function does not use non-generic status codes |
109 | // This function does not use non-generic status codes |
106 | result := FALSE; |
110 | result := FALSE; |
107 | end; |
111 | end; |
108 | 112 | ||
109 | exports |
113 | exports |
110 | PluginInterfaceID name mnPluginInterfaceID, |
114 | PluginInterfaceID name mnPluginInterfaceID, |
111 | PluginIdentifier name mnPluginIdentifier, |
115 | PluginIdentifier name mnPluginIdentifier, |
112 | PluginNameW name mnPluginNameW, |
116 | PluginNameW name mnPluginNameW, |
113 | PluginVendorW name mnPluginVendorW, |
117 | PluginVendorW name mnPluginVendorW, |
114 | PluginVersionW name mnPluginVersionW, |
118 | PluginVersionW name mnPluginVersionW, |
115 | IdentificationMethodNameW name mnIdentificationMethodNameW, |
119 | IdentificationMethodNameW name mnIdentificationMethodNameW, |
116 | IdentificationStringW name mnIdentificationStringW, |
120 | IdentificationStringW name mnIdentificationStringW, |
117 | CheckLicense name mnCheckLicense, |
121 | CheckLicense name mnCheckLicense, |
118 | DescribeOwnStatusCodeW name mnDescribeOwnStatusCodeW; |
122 | DescribeOwnStatusCodeW name mnDescribeOwnStatusCodeW; |
119 | 123 | ||
120 | end. |
124 | end. |
121 | 125 |