Subversion Repositories userdetect2

Rev

Rev 69 | Rev 71 | 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_STATUS; cdecl;
  22. var
  23.   sl, sl2: TStringList;
  24.   i: integer;
  25.   ip, mac: string;
  26.   ec: DWORD;
  27. begin
  28.   sl := TStringList.Create;
  29.   sl2 := TStringList.Create;
  30.   try
  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.  
  43.     for i := 0 to sl.Count-1 do
  44.     begin
  45.       ip := sl.Strings[i];
  46.       ec := GetMACAddress(ip, mac);
  47.       if ec = ERROR_NOT_SUPPORTED then
  48.       begin
  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
  56.         sl2.add(mac);
  57.       end;
  58.     end;
  59.     result := UD2_WriteStringListToPointerW(lpIdentifier, cchSize, sl2);
  60.   finally
  61.     sl.Free;
  62.     sl2.Free;
  63.   end;
  64. end;
  65.  
  66. function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  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';
  76.   result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
  77. end;
  78.  
  79. function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  80. begin
  81.   result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
  82. end;
  83.  
  84. function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  85. begin
  86.   result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
  87. end;
  88.  
  89. function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  90. var
  91.   stIdentificationMethodName: WideString;
  92. begin
  93.   stIdentificationMethodName := 'DHCP_MAC';
  94.   result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
  95. end;
  96.  
  97. function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
  98. begin
  99.   result := UD2_STATUS_OK_LICENSED;
  100. end;
  101.  
  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.  
  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,
  116.   CheckLicense              name mnCheckLicense,
  117.   DescribeOwnStatusCodeW    name mnDescribeOwnStatusCodeW;
  118.  
  119. end.
  120.