Subversion Repositories userdetect2

Rev

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

  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.  
  21. function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; 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.     if GetLocalMACAddressList(sl2) <> NO_ERROR then
  31.     begin
  32.       result := UD2_STATUS_NOTAVAIL_API_CALL_FAILURE;
  33.       Exit;
  34.     end;
  35.  
  36.     // This procedure should not find any more MAC addresses...
  37.     GetLocalIPAddressList(sl);
  38.     for i := 0 to sl.Count-1 do
  39.     begin
  40.       ip := sl.Strings[i];
  41.       if (GetMACAddress(ip, mac) = S_OK) and
  42.          (mac <> '') and
  43.          (sl2.IndexOf(mac) = -1) then
  44.       begin
  45.         sl2.add(mac);
  46.       end;
  47.     end;
  48.     result := UD2_WriteStringListToPointerW(lpIdentifier, cchSize, sl2);
  49.   finally
  50.     sl.Free;
  51.     sl2.Free;
  52.   end;
  53. end;
  54.  
  55. function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  56. var
  57.   stPluginName: WideString;
  58.   primaryLangID: Byte;
  59. begin
  60.   primaryLangID := wLangID and $00FF;
  61.   if primaryLangID = LANG_GERMAN then
  62.     stPluginName := 'MAC-Adressen'
  63.   else
  64.     stPluginName := 'MAC addresses';
  65.   result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
  66. end;
  67.  
  68. function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  69. begin
  70.   result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
  71. end;
  72.  
  73. function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  74. begin
  75.   result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
  76. end;
  77.  
  78. function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  79. var
  80.   stIdentificationMethodName: WideString;
  81. begin
  82.   stIdentificationMethodName := 'LAN_MAC';
  83.   result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
  84. end;
  85.  
  86. function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
  87. begin
  88.   result := UD2_STATUS_OK_LICENSED;
  89. end;
  90.  
  91. exports
  92.   PluginInterfaceID         name mnPluginInterfaceID,
  93.   PluginIdentifier          name mnPluginIdentifier,
  94.   PluginNameW               name mnPluginNameW,
  95.   PluginVendorW             name mnPluginVendorW,
  96.   PluginVersionW            name mnPluginVersionW,
  97.   IdentificationMethodNameW name mnIdentificationMethodNameW,
  98.   IdentificationStringW     name mnIdentificationStringW,
  99.   CheckLicense              name mnCheckLicense;
  100.  
  101. end.
  102.