Subversion Repositories userdetect2

Rev

Rev 89 | Rev 92 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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