Subversion Repositories userdetect2

Rev

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

  1. library UserName;
  2.  
  3. uses
  4.   Windows,
  5.   SysUtils,
  6.   Classes,
  7.   MiscUtils,
  8.   UD2_PluginIntf in '..\UD2_PluginIntf.pas',
  9.   UD2_PluginUtils in '..\UD2_PluginUtils.pas',
  10.   UD2_PluginStatus in '..\UD2_PluginStatus.pas';
  11.  
  12. {$R *.res}
  13.  
  14. const
  15.   PLUGIN_GUID: TGUID = '{B1DF529C-BE26-4D06-92D3-23F421CEEE11}';
  16.  
  17. function PluginIdentifier: TGUID; cdecl;
  18. begin
  19.   result := PLUGIN_GUID;
  20. end;
  21.  
  22. function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  23. var
  24.   stIdentifier: WideString;
  25. begin
  26.   try
  27.     stIdentifier := GetUserName;
  28.     result := UD2_WritePascalStringToPointerW(lpIdentifier, cchSize, stIdentifier);
  29.   except
  30.     on E: Exception do result := UD2_STATUS_HandleException(E);
  31.   end;
  32. end;
  33.  
  34. function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  35. var
  36.   stPluginName: WideString;
  37.   primaryLangID: Byte;
  38. begin
  39.   primaryLangID := wLangID and $00FF;
  40.   if primaryLangID = LANG_GERMAN then
  41.     stPluginName := 'Benutzername'
  42.   else
  43.     stPluginName := 'Username';
  44.   result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
  45. end;
  46.  
  47. function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  48. begin
  49.   result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
  50. end;
  51.  
  52. function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  53. begin
  54.   result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
  55. end;
  56.  
  57. function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  58. var
  59.   stIdentificationMethodName: WideString;
  60. begin
  61.   stIdentificationMethodName := 'UserName';
  62.   result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
  63. end;
  64.  
  65. function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
  66. begin
  67.   result := UD2_STATUS_OK_LICENSED;
  68. end;
  69.  
  70. function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl;
  71. begin
  72.   // This function does not use non-generic status codes
  73.   result := FALSE;
  74. end;
  75.  
  76. exports
  77.   PluginInterfaceID         name mnPluginInterfaceID,
  78.   PluginIdentifier          name mnPluginIdentifier,
  79.   PluginNameW               name mnPluginNameW,
  80.   PluginVendorW             name mnPluginVendorW,
  81.   PluginVersionW            name mnPluginVersionW,
  82.   IdentificationMethodNameW name mnIdentificationMethodNameW,
  83.   IdentificationStringW     name mnIdentificationStringW,
  84.   CheckLicense              name mnCheckLicense,
  85.   DescribeOwnStatusCodeW    name mnDescribeOwnStatusCodeW;
  86.  
  87. end.
  88.