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