Subversion Repositories delphiutils

Rev

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

  1. library DHCP_IP;
  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 = '{3E0B99F7-E062-4FF1-B656-7D512BE90C47}';
  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: TStringList;
  24.   ec: DWORD;
  25. begin
  26.   sl := TStringList.Create;
  27.   try
  28.     ec := GetDHCPIPAddressList(sl);
  29.     if ec = ERROR_NOT_SUPPORTED then
  30.     begin
  31.       result := UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED;
  32.       Exit;
  33.     end
  34.     else if ec <> ERROR_SUCCESS then
  35.     begin
  36.       result := UD2_STATUS_NOTAVAIL_API_CALL_FAILURE;
  37.       Exit;
  38.     end;
  39.     result := UD2_WriteStringListToPointerW(lpIdentifier, cchSize, sl);
  40.   finally
  41.     sl.Free;
  42.   end;
  43. end;
  44.  
  45. function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  46. var
  47.   stPluginName: WideString;
  48.   primaryLangID: Byte;
  49. begin
  50.   primaryLangID := wLangID and $00FF;
  51.   if primaryLangID = LANG_GERMAN then
  52.     stPluginName := 'IP-Adresse der DHCP-Server'
  53.   else
  54.     stPluginName := 'DHCP IP addresses';
  55.   result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
  56. end;
  57.  
  58. function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  59. begin
  60.   result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
  61. end;
  62.  
  63. function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  64. begin
  65.   result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
  66. end;
  67.  
  68. function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  69. var
  70.   stIdentificationMethodName: WideString;
  71. begin
  72.   stIdentificationMethodName := 'DHCP_IP';
  73.   result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
  74. end;
  75.  
  76. function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
  77. begin
  78.   result := UD2_STATUS_OK_LICENSED;
  79. end;
  80.  
  81. function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl;
  82. begin
  83.   // This function does not use non-generic status codes
  84.   result := FALSE;
  85. end;
  86.  
  87. exports
  88.   PluginInterfaceID         name mnPluginInterfaceID,
  89.   PluginIdentifier          name mnPluginIdentifier,
  90.   PluginNameW               name mnPluginNameW,
  91.   PluginVendorW             name mnPluginVendorW,
  92.   PluginVersionW            name mnPluginVersionW,
  93.   IdentificationMethodNameW name mnIdentificationMethodNameW,
  94.   IdentificationStringW     name mnIdentificationStringW,
  95.   CheckLicense              name mnCheckLicense,
  96.   DescribeOwnStatusCodeW    name mnDescribeOwnStatusCodeW;
  97.  
  98. end.
  99.