Subversion Repositories userdetect2

Rev

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

  1. library DriveSerial;
  2.  
  3. uses
  4.   Windows,
  5.   SysUtils,
  6.   Classes,
  7.   ActiveX,
  8.   UD2_PluginIntf in '..\UD2_PluginIntf.pas',
  9.   UD2_PluginUtils in '..\UD2_PluginUtils.pas',
  10.   UD2_PluginStatus in '..\UD2_PluginStatus.pas',
  11.   hddinfo in 'Utils\hddinfo.pas';
  12.  
  13. {$R *.res}
  14.  
  15. const
  16.   PLUGIN_GUID: TGUID = '{2978C8D6-02A8-4D29-83D7-62EA5252F807}';
  17.  
  18. function PluginIdentifier: TGUID; cdecl;
  19. begin
  20.   result := PLUGIN_GUID;
  21. end;
  22.  
  23. function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  24. begin
  25.   result := UD2_STATUS_NOTAVAIL_ONLY_ACCEPT_DYNAMIC;
  26. end;
  27.  
  28. function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  29. var
  30.   stPluginName: WideString;
  31.   primaryLangID: Byte;
  32. begin
  33.   primaryLangID := wLangID and $00FF;
  34.   if primaryLangID = LANG_GERMAN then
  35.     stPluginName := 'Datenträger-Seriennummer'
  36.   else
  37.     stPluginName := 'Drive Serial Number';
  38.   result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
  39. end;
  40.  
  41. function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  42. begin
  43.   result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
  44. end;
  45.  
  46. function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
  47. begin
  48.   result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
  49. end;
  50.  
  51. function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
  52. var
  53.   stIdentificationMethodName: WideString;
  54. begin
  55.   stIdentificationMethodName := 'DriveSerial';
  56.   result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
  57. end;
  58.  
  59. function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
  60. begin
  61.   result := UD2_STATUS_OK_LICENSED;
  62. end;
  63.  
  64. function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl;
  65. begin
  66.   // This function does not use non-generic status codes
  67.   result := FALSE;
  68. end;
  69.  
  70. function DynamicIdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD; lpDynamicData: LPWSTR): UD2_STATUS; cdecl;
  71. var
  72.   stIdentifier: WideString;
  73.   driveletter: char;
  74. begin
  75.   try
  76.     if Copy(string(lpDynamicData), 2, 1) <> ':' then
  77.     begin
  78.       result := UD2_STATUS_NOTAVAIL_INVALID_INPUT;
  79.       exit;
  80.     end;
  81.  
  82.     driveletter := Copy(UpperCase(lpDynamicData), 1, 1)[1];
  83.  
  84.     if not (driveletter in ['A'..'Z']) then
  85.     begin
  86.       result := UD2_STATUS_NOTAVAIL_INVALID_INPUT;
  87.       exit;
  88.     end;
  89.  
  90.     CoInitialize(nil);
  91.     try
  92.       stIdentifier := GetDiskSerial(driveletter); // driveletter must be upper case
  93.     finally
  94.       CoUninitialize;
  95.     end;
  96.     result := UD2_WritePascalStringToPointerW(lpIdentifier, cchSize, stIdentifier);
  97.   except
  98.     on E: Exception do result := UD2_STATUS_HandleException(E);
  99.   end;
  100. end;
  101.  
  102.  
  103. exports
  104.   PluginInterfaceID         name mnPluginInterfaceID,
  105.   PluginIdentifier          name mnPluginIdentifier,
  106.   PluginNameW               name mnPluginNameW,
  107.   PluginVendorW             name mnPluginVendorW,
  108.   PluginVersionW            name mnPluginVersionW,
  109.   IdentificationMethodNameW name mnIdentificationMethodNameW,
  110.   IdentificationStringW     name mnIdentificationStringW,
  111.   CheckLicense              name mnCheckLicense,
  112.   DescribeOwnStatusCodeW    name mnDescribeOwnStatusCodeW,
  113.   DynamicIdentificationStringW name mnDynamicIdentificationStringW;
  114.  
  115. end.
  116.