Subversion Repositories userdetect2

Rev

Rev 68 | Rev 70 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 daniel-mar 1
unit UD2_PluginIntf;
2
 
3
interface
4
 
5
{$IF CompilerVersion >= 25.0}
6
{$LEGACYIFEND ON}
7
{$IFEND}
8
 
9
uses
69 daniel-mar 10
  Windows, SysUtils;
68 daniel-mar 11
 
12
const
13
  GUID_USERDETECT2_IDPLUGIN_V1: TGUID = '{6C26245E-F79A-416C-8C73-BEA3EC18BB6E}';
14
 
15
const
16
  mnPluginInterfaceID         = 'PluginInterfaceID';
17
  mnPluginIdentifier          = 'PluginIdentifier';
18
  mnPluginNameW               = 'PluginNameW';
19
  mnPluginVersionW            = 'PluginVersionW';
20
  mnPluginVendorW             = 'PluginVendorW';
21
  mnCheckLicense              = 'CheckLicense';
22
  mnIdentificationMethodNameW = 'IdentificationMethodNameW';
23
  mnIdentificationStringW     = 'IdentificationStringW';
24
 
25
{$IF not Declared(LPVOID)}
26
type
27
  LPVOID = Pointer;
28
{$IFEND}
29
 
30
type
69 daniel-mar 31
  UD2_STATUS = DWORD;
32
  UD2_STATUSCAT = $0..$F;
33
  UD2_STATUSAUTH = $000..$FFF;
34
  UD2_STATUSMSG = $0000..$FFFF;
68 daniel-mar 35
 
36
const
69 daniel-mar 37
  UD2_STATUSCAT_SUCCESS   : UD2_STATUSCAT = $8;
38
  UD2_STATUSCAT_NOT_AVAIL : UD2_STATUSCAT = $9;        
39
  UD2_STATUSCAT_ERROR     : UD2_STATUSCAT = $A;
68 daniel-mar 40
 
69 daniel-mar 41
  UD2_STATUSAUTH_GENERIC : UD2_STATUSAUTH = $100;
42
 
43
  UD2_STATUS_OK_UNSPECIFIED : UD2_STATUS = $81000000;
44
  UD2_STATUS_OK_SINGLELINE  : UD2_STATUS = $81000001;
45
  UD2_STATUS_OK_MULTILINE   : UD2_STATUS = $81000002;
46
  UD2_STATUS_OK_LICENSED    : UD2_STATUS = $81000003;
47
 
48
  UD2_STATUS_NOTAVAIL_UNSPECIFIED      : UD2_STATUS = $91000000;
49
  UD2_STATUS_NOTAVAIL_OS_NOT_SUPPORTED : UD2_STATUS = $91000001;
50
  UD2_STATUS_NOTAVAIL_HW_NOT_SUPPORTED : UD2_STATUS = $91000002;
51
  UD2_STATUS_NOTAVAIL_NO_ENTITIES      : UD2_STATUS = $91000003;
52
  UD2_STATUS_NOTAVAIL_API_CALL_FAILURE : UD2_STATUS = $91000004;
53
 
54
  UD2_STATUS_ERROR_UNSPECIFIED         : UD2_STATUS = $A1000000;
55
  UD2_STATUS_ERROR_BUFFER_TOO_SMALL    : UD2_STATUS = $A1000001;
56
  UD2_STATUS_ERROR_INVALID_ARGS        : UD2_STATUS = $A1000002;
57
  UD2_STATUS_ERROR_PLUGIN_NOT_LICENSED : UD2_STATUS = $A1000003;
58
 
59
function UD2_STATUS_Construct(cat: UD2_STATUSCAT;
60
  auth: UD2_STATUSAUTH; msg: UD2_STATUSMSG): UD2_STATUS;
61
function UD2_STATUS_GetCategory(dwStatus: UD2_STATUS): UD2_STATUSCAT;
62
function UD2_STATUS_GetAuthority(dwStatus: UD2_STATUS): UD2_STATUSAUTH;
63
function UD2_STATUS_GetMessage(dwStatus: UD2_STATUS): UD2_STATUSMSG;
64
function UD2_STATUS_Successful(dwStatus: UD2_STATUS): boolean;
65
function UD2_STATUS_NotAvail(dwStatus: UD2_STATUS): boolean;
66
function UD2_STATUS_Failed(dwStatus: UD2_STATUS): boolean;
67
function UD2_STATUS_FormatStatusCode(dwStatus: UD2_STATUS): string;
68
function UD2_STATUS_IsSpecific(dwStatus: UD2_STATUS): boolean;
69
 
68 daniel-mar 70
type
71
  TFuncPluginInterfaceID = function(): TGUID; cdecl;
72
  TFuncPluginIdentifier = function(): TGUID; cdecl;
69 daniel-mar 73
  TFuncPluginNameW = function(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
74
  TFuncPluginVersionW = function(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
75
  TFuncPluginVendorW = function(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
76
  TFuncCheckLicense = function(lpReserved: LPVOID): UD2_STATUS; cdecl;
77
  TFuncIdentificationMethodNameW = function(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
78
  TFuncIdentificationStringW = function(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
68 daniel-mar 79
 
80
const
81
  UD2_MULTIPLE_ITEMS_DELIMITER = #10;
82
 
83
function PluginInterfaceID: TGUID; cdecl;
84
 
85
implementation
86
 
69 daniel-mar 87
function UD2_STATUS_Construct(cat: UD2_STATUSCAT;
88
  auth: UD2_STATUSAUTH; msg: UD2_STATUSMSG): UD2_STATUS;
89
begin
90
  result := (cat shl 28) + (auth shl 16) + msg;
91
end;
92
 
93
function UD2_STATUS_GetCategory(dwStatus: UD2_STATUS): UD2_STATUSCAT;
94
begin
95
  result := (dwStatus and $F0000000) shr 28;
96
end;
97
 
98
function UD2_STATUS_GetAuthority(dwStatus: UD2_STATUS): UD2_STATUSAUTH;
99
begin
100
  result := (dwStatus and $0FFF0000) shr 16;
101
end;
102
 
103
function UD2_STATUS_GetMessage(dwStatus: UD2_STATUS): UD2_STATUSMSG;
104
begin
105
  result := dwStatus and $0000FFFF;
106
end;
107
 
108
function UD2_STATUS_Successful(dwStatus: UD2_STATUS): boolean;
109
begin
110
  result := UD2_STATUS_GetCategory(dwStatus) = UD2_STATUSCAT_SUCCESS;
111
end;
112
 
113
function UD2_STATUS_NotAvail(dwStatus: UD2_STATUS): boolean;
114
begin
115
  result := UD2_STATUS_GetCategory(dwStatus) = UD2_STATUSCAT_NOT_AVAIL;
116
end;
117
 
118
function UD2_STATUS_Failed(dwStatus: UD2_STATUS): boolean;
119
begin
120
  result := UD2_STATUS_GetCategory(dwStatus) = UD2_STATUSCAT_ERROR;
121
end;
122
 
123
function UD2_STATUS_FormatStatusCode(dwStatus: UD2_STATUS): string;
124
begin
125
  result := IntToHex(UD2_STATUS_GetCategory(dwStatus), 1) + ' ' +
126
            IntToHex(UD2_STATUS_GetAuthority(dwStatus), 3) + ' ' +
127
            IntToHex(UD2_STATUS_GetMessage(dwStatus), 4);
128
end;
129
 
130
function UD2_STATUS_IsSpecific(dwStatus: UD2_STATUS): boolean;
131
begin
132
  result := (dwStatus and $0000FFFF) <> 0;
133
end;
134
 
68 daniel-mar 135
function PluginInterfaceID: TGUID; cdecl;
136
begin
137
  result := GUID_USERDETECT2_IDPLUGIN_V1;
138
end;
139
 
140
end.