Subversion Repositories userdetect2

Rev

Rev 69 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 daniel-mar 1
library ComputerName;
2
 
3
uses
4
  Windows,
5
  SysUtils,
6
  Classes,
7
  UD2_PluginIntf in '..\UD2_PluginIntf.pas',
8
  UD2_PluginUtils in '..\UD2_PluginUtils.pas';
9
 
10
{$R *.res}
11
 
12
const
13
  PLUGIN_GUID: TGUID = '{2AD004FF-6BFD-4038-B75B-9527DEABA28F}';
14
 
15
function PluginIdentifier: TGUID; cdecl;
16
begin
17
  result := PLUGIN_GUID;
18
end;
19
 
20
function GetComputerName: string;
21
// http://www.delphi-treff.de/tipps-tricks/netzwerkinternet/netzwerkeigenschaften/computernamen-des-eigenen-rechners-ermitteln/
22
var
23
  Len: DWORD;
24
begin
25
  Len := MAX_COMPUTERNAME_LENGTH+1;
26
  SetLength(Result,Len);
27
  if Windows.GetComputerName(PChar(Result), Len) then
28
    SetLength(Result,Len)
29
  else
30
    RaiseLastOSError;
31
end;
32
 
33
function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUSCODE; cdecl;
34
var
35
  stIdentifier: WideString;
36
begin
37
  stIdentifier := GetComputerName;
38
  result := WritePascalStringToPointerW(lpIdentifier, cchSize, stIdentifier);
39
end;
40
 
41
function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
42
var
43
  stPluginName: WideString;
44
  primaryLangID: Byte;
45
begin
46
  primaryLangID := wLangID and $00FF;
47
  if primaryLangID = LANG_GERMAN then
48
    stPluginName := 'Computer-Name'
49
  else
50
    stPluginName := 'Computer name';
51
  result := WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
52
end;
53
 
54
function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
55
begin
56
  result := WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
57
end;
58
 
59
function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUSCODE; cdecl;
60
begin
61
  result := WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
62
end;
63
 
64
function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUSCODE; cdecl;
65
var
66
  stIdentificationMethodName: WideString;
67
begin
68
  stIdentificationMethodName := 'ComputerName';
69
  result := WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
70
end;
71
 
72
function CheckLicense(lpReserved: LPVOID): UD2_STATUSCODE; cdecl;
73
begin
74
  result := UD2_STATUS_OK;
75
end;
76
 
77
exports
78
  PluginInterfaceID         name mnPluginInterfaceID,
79
  PluginIdentifier          name mnPluginIdentifier,
80
  PluginNameW               name mnPluginNameW,
81
  PluginVendorW             name mnPluginVendorW,
82
  PluginVersionW            name mnPluginVersionW,
83
  IdentificationMethodNameW name mnIdentificationMethodNameW,
84
  IdentificationStringW     name mnIdentificationStringW,
85
  CheckLicense              name mnCheckLicense;
86
 
87
end.