Subversion Repositories userdetect2

Rev

Rev 69 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  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.  
  21. function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUSCODE; cdecl;
  22. var
  23.   sl, sl2: TStringList;
  24.   i: integer;
  25.   ip, mac: string;
  26. begin
  27.   sl := TStringList.Create;
  28.   sl2 := TStringList.Create;
  29.   try
  30.     GetDHCPIPAddressList(sl);
  31.     for i := 0 to sl.Count-1 do
  32.     begin
  33.       ip := sl.Strings[i];
  34.       if (GetMACAddress(ip, mac) = S_OK) and
  35.          (mac <> '') and
  36.          (sl2.IndexOf(mac) = -1) then
  37.       begin
  38.         sl2.add(mac);
  39.       end;
  40.     end;
  41.     result := WriteStringListToPointerW(lpIdentifier, cchSize, sl2);
  42.   finally
  43.     sl.Free;
  44.     sl2.Free;
  45.   end;
  46. end;
  47.  
  48. function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
  49. var
  50.   stPluginName: WideString;
  51.   primaryLangID: Byte;
  52. begin
  53.   primaryLangID := wLangID and $00FF;
  54.   if primaryLangID = LANG_GERMAN then
  55.     stPluginName := 'MAC-Adressen der DHCP-Server'
  56.   else
  57.     stPluginName := 'DHCP MAC addresses';
  58.   result := WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
  59. end;
  60.  
  61. function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
  62. begin
  63.   result := WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
  64. end;
  65.  
  66. function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
  67. begin
  68.   result := WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
  69. end;
  70.  
  71. function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUSCODE; cdecl;
  72. var
  73.   stIdentificationMethodName: WideString;
  74. begin
  75.   stIdentificationMethodName := 'DHCP_MAC';
  76.   result := WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
  77. end;
  78.  
  79. function CheckLicense(lpReserved: LPVOID): UD2_STATUSCODE; cdecl;
  80. begin
  81.   result := UD2_STATUS_OK;
  82. end;
  83.  
  84. exports
  85.   PluginInterfaceID         name mnPluginInterfaceID,
  86.   PluginIdentifier          name mnPluginIdentifier,
  87.   PluginNameW               name mnPluginNameW,
  88.   PluginVendorW             name mnPluginVendorW,
  89.   PluginVersionW            name mnPluginVersionW,
  90.   IdentificationMethodNameW name mnIdentificationMethodNameW,
  91.   IdentificationStringW     name mnIdentificationStringW,
  92.   CheckLicense              name mnCheckLicense;
  93.  
  94. end.
  95.