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 LAN_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 = '{8E1AA598-67A6-4128-BB9F-7E624647F584}'; |
||
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 := GetLocalMACAddressList(sl2); |
32 | if ec = ERROR_NOT_SUPPORTED then |
||
68 | daniel-mar | 33 | begin |
70 | daniel-mar | 34 | result := UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED; |
35 | Exit; |
||
36 | end |
||
37 | else if ec <> ERROR_SUCCESS then |
||
38 | begin |
||
69 | daniel-mar | 39 | result := UD2_STATUS_NOTAVAIL_API_CALL_FAILURE; |
68 | daniel-mar | 40 | Exit; |
41 | end; |
||
42 | |||
43 | // This procedure should not find any more MAC addresses... |
||
44 | GetLocalIPAddressList(sl); |
||
45 | for i := 0 to sl.Count-1 do |
||
46 | begin |
||
47 | ip := sl.Strings[i]; |
||
70 | daniel-mar | 48 | ec := GetMACAddress(ip, mac); |
49 | if ec = ERROR_NOT_SUPPORTED then |
||
68 | daniel-mar | 50 | begin |
70 | daniel-mar | 51 | result := UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED; |
52 | Exit; |
||
53 | end |
||
54 | else if (ec = S_OK) and |
||
55 | (mac <> '') and |
||
56 | (sl2.IndexOf(mac) = -1) then |
||
57 | begin |
||
68 | daniel-mar | 58 | sl2.add(mac); |
59 | end; |
||
60 | end; |
||
69 | daniel-mar | 61 | result := UD2_WriteStringListToPointerW(lpIdentifier, cchSize, sl2); |
68 | daniel-mar | 62 | finally |
63 | sl.Free; |
||
64 | sl2.Free; |
||
65 | end; |
||
66 | end; |
||
67 | |||
69 | daniel-mar | 68 | function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
68 | daniel-mar | 69 | var |
70 | stPluginName: WideString; |
||
71 | primaryLangID: Byte; |
||
72 | begin |
||
73 | primaryLangID := wLangID and $00FF; |
||
74 | if primaryLangID = LANG_GERMAN then |
||
75 | stPluginName := 'MAC-Adressen' |
||
76 | else |
||
77 | stPluginName := 'MAC addresses'; |
||
69 | daniel-mar | 78 | result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName); |
68 | daniel-mar | 79 | end; |
80 | |||
69 | daniel-mar | 81 | function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
68 | daniel-mar | 82 | begin |
69 | daniel-mar | 83 | result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft'); |
68 | daniel-mar | 84 | end; |
85 | |||
69 | daniel-mar | 86 | function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl; |
68 | daniel-mar | 87 | begin |
69 | daniel-mar | 88 | result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0'); |
68 | daniel-mar | 89 | end; |
90 | |||
69 | daniel-mar | 91 | function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl; |
68 | daniel-mar | 92 | var |
93 | stIdentificationMethodName: WideString; |
||
94 | begin |
||
95 | stIdentificationMethodName := 'LAN_MAC'; |
||
69 | daniel-mar | 96 | result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName); |
68 | daniel-mar | 97 | end; |
98 | |||
69 | daniel-mar | 99 | function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl; |
68 | daniel-mar | 100 | begin |
69 | daniel-mar | 101 | result := UD2_STATUS_OK_LICENSED; |
68 | daniel-mar | 102 | end; |
103 | |||
70 | daniel-mar | 104 | function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl; |
105 | begin |
||
106 | // This function does not use non-generic status codes |
||
107 | result := FALSE; |
||
108 | end; |
||
109 | |||
68 | daniel-mar | 110 | exports |
111 | PluginInterfaceID name mnPluginInterfaceID, |
||
112 | PluginIdentifier name mnPluginIdentifier, |
||
113 | PluginNameW name mnPluginNameW, |
||
114 | PluginVendorW name mnPluginVendorW, |
||
115 | PluginVersionW name mnPluginVersionW, |
||
116 | IdentificationMethodNameW name mnIdentificationMethodNameW, |
||
117 | IdentificationStringW name mnIdentificationStringW, |
||
70 | daniel-mar | 118 | CheckLicense name mnCheckLicense, |
119 | DescribeOwnStatusCodeW name mnDescribeOwnStatusCodeW; |
||
68 | daniel-mar | 120 | |
121 | end. |