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