Subversion Repositories delphiutils

Rev

Rev 68 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68 Rev 69
Line 5... Line 5...
5
{$IF CompilerVersion >= 25.0}
5
{$IF CompilerVersion >= 25.0}
6
{$LEGACYIFEND ON}
6
{$LEGACYIFEND ON}
7
{$IFEND}
7
{$IFEND}
8
 
8
 
9
uses
9
uses
10
  Windows;
10
  Windows, SysUtils;
11
 
11
 
12
const
12
const
13
  GUID_USERDETECT2_IDPLUGIN_V1: TGUID = '{6C26245E-F79A-416C-8C73-BEA3EC18BB6E}';
13
  GUID_USERDETECT2_IDPLUGIN_V1: TGUID = '{6C26245E-F79A-416C-8C73-BEA3EC18BB6E}';
14
 
14
 
15
const
15
const
Line 26... Line 26...
26
type
26
type
27
  LPVOID = Pointer;
27
  LPVOID = Pointer;
28
{$IFEND}
28
{$IFEND}
29
 
29
 
30
type
30
type
31
  UD2_STATUSCODE = DWORD;
31
  UD2_STATUS = DWORD;
-
 
32
  UD2_STATUSCAT = $0..$F;
-
 
33
  UD2_STATUSAUTH = $000..$FFF;
-
 
34
  UD2_STATUSMSG = $0000..$FFFF;
32
 
35
 
33
const
36
const
-
 
37
  UD2_STATUSCAT_SUCCESS   : UD2_STATUSCAT = $8;
34
  // We have chosen these numbers, to avoid that people use
38
  UD2_STATUSCAT_NOT_AVAIL : UD2_STATUSCAT = $9;        
-
 
39
  UD2_STATUSCAT_ERROR     : UD2_STATUSCAT = $A;
-
 
40
 
-
 
41
  UD2_STATUSAUTH_GENERIC : UD2_STATUSAUTH = $100;
-
 
42
 
-
 
43
  UD2_STATUS_OK_UNSPECIFIED : UD2_STATUS = $81000000;
35
  // "return FALSE" ("return 0") to declare an error, and
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
 
36
  // "return TRUE" ("return 1") to declare a successful operation.
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;
37
  // TODO: visible und invisible module errors, z.b. unavailable wegen winapi etc.
51
  UD2_STATUS_NOTAVAIL_NO_ENTITIES      : UD2_STATUS = $91000003;
38
  // --> mask machen: sucessful, failed, failed hard, official oder userdefined
52
  UD2_STATUS_NOTAVAIL_API_CALL_FAILURE : UD2_STATUS = $91000004;
-
 
53
 
39
  UD2_STATUS_OK               : UD2_STATUSCODE = $10000000;
54
  UD2_STATUS_ERROR_UNSPECIFIED         : UD2_STATUS = $A1000000;
40
  UD2_STATUS_BUFFER_TOO_SMALL : UD2_STATUSCODE = $00001000;
55
  UD2_STATUS_ERROR_BUFFER_TOO_SMALL    : UD2_STATUS = $A1000001;
41
  UD2_STATUS_INVALID_ARGS     : UD2_STATUSCODE = $00001001;
56
  UD2_STATUS_ERROR_INVALID_ARGS        : UD2_STATUS = $A1000002;
42
  UD2_STATUS_NOT_LICENSED     : UD2_STATUSCODE = $00001002;
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;
43
 
69
 
44
type
70
type
45
  TFuncPluginInterfaceID = function(): TGUID; cdecl;
71
  TFuncPluginInterfaceID = function(): TGUID; cdecl;
46
  TFuncPluginIdentifier = function(): TGUID; cdecl;
72
  TFuncPluginIdentifier = function(): TGUID; cdecl;
47
  TFuncPluginNameW = function(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
73
  TFuncPluginNameW = function(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
48
  TFuncPluginVersionW = function(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
74
  TFuncPluginVersionW = function(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
49
  TFuncPluginVendorW = function(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
75
  TFuncPluginVendorW = function(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
50
  TFuncCheckLicense = function(lpReserved: LPVOID): UD2_STATUSCODE; cdecl;
76
  TFuncCheckLicense = function(lpReserved: LPVOID): UD2_STATUS; cdecl;
51
  TFuncIdentificationMethodNameW = function(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUSCODE; cdecl;
77
  TFuncIdentificationMethodNameW = function(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
52
  TFuncIdentificationStringW = function(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUSCODE; cdecl;
78
  TFuncIdentificationStringW = function(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
53
 
79
 
54
const
80
const
55
  UD2_MULTIPLE_ITEMS_DELIMITER = #10;
81
  UD2_MULTIPLE_ITEMS_DELIMITER = #10;
56
 
82
 
57
function PluginInterfaceID: TGUID; cdecl;
83
function PluginInterfaceID: TGUID; cdecl;
58
 
84
 
59
implementation
85
implementation
60
 
86
 
-
 
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
 
61
function PluginInterfaceID: TGUID; cdecl;
135
function PluginInterfaceID: TGUID; cdecl;
62
begin
136
begin
63
  result := GUID_USERDETECT2_IDPLUGIN_V1;
137
  result := GUID_USERDETECT2_IDPLUGIN_V1;
64
end;
138
end;
65
 
139