Subversion Repositories userdetect2

Rev

Rev 71 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. library ComputerName;
  2.  
  3. uses
  4.   Windows,
  5.   SysUtils,
  6.   Classes,
  7.   UD2_PluginIntf in '..\UD2_PluginIntf.pas',
  8.   UD2_PluginUtils in '..\UD2_PluginUtils.pas',
  9.   UD2_PluginStatus in '..\UD2_PluginStatus.pas';
  10.  
  11. {$R *.res}
  12.  
  13. const
  14.   PLUGIN_GUID: TGUID = '{2AD004FF-6BFD-4038-B75B-9527DEABA28F}';
  15.  
  16. function PluginIdentifier: TGUID; cdecl;
  17. begin
  18.   result := PLUGIN_GUID;
  19. end;
  20.  
  21. function GetComputerName: string;
  22. // http://www.delphi-treff.de/tipps-tricks/netzwerkinternet/netzwerkeigenschaften/computernamen-des-eigenen-rechners-ermitteln/
  23. var
  24.   Len: DWORD;
  25. begin
  26.   Len := MAX_COMPUTERNAME_LENGTH+1;
  27.   SetLength(Result,Len);
  28.   if Windows.GetComputerName(PChar(Result), Len) then
  29.     SetLength(Result,Len)
  30.   else
  31.     RaiseLastOSError;
  32. end;
  33.  
  34. function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  35. var
  36.   stIdentifier: WideString;
  37. begin
  38.   stIdentifier := GetComputerName;
  39.   result := UD2_WritePascalStringToPointerW(lpIdentifier, cchSize, stIdentifier);
  40. end;
  41.  
  42. function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  43. var
  44.   stPluginName: WideString;
  45.   primaryLangID: Byte;
  46. begin
  47.   primaryLangID := wLangID and $00FF;
  48.   if primaryLangID = LANG_GERMAN then
  49.     stPluginName := 'Computer-Name'
  50.   else
  51.     stPluginName := 'Computer name';
  52.   result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
  53. end;
  54.  
  55. function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  56. begin
  57.   result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
  58. end;
  59.  
  60. function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  61. begin
  62.   result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
  63. end;
  64.  
  65. function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  66. var
  67.   stIdentificationMethodName: WideString;
  68. begin
  69.   stIdentificationMethodName := 'ComputerName';
  70.   result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
  71. end;
  72.  
  73. function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
  74. begin
  75.   result := UD2_STATUS_OK_LICENSED;
  76. end;
  77.  
  78. function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl;
  79. begin
  80.   // This function does not use non-generic status codes
  81.   result := FALSE;
  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.   DescribeOwnStatusCodeW    name mnDescribeOwnStatusCodeW;
  94.  
  95. end.
  96.