Subversion Repositories delphiutils

Rev

Rev 69 | Go to most recent revision | Details | Compare with Previous | 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
 
69 daniel-mar 33
function IdentificationStringW(lpIdentifier: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
68 daniel-mar 34
var
35
  stIdentifier: WideString;
36
begin
37
  stIdentifier := GetComputerName;
69 daniel-mar 38
  result := UD2_WritePascalStringToPointerW(lpIdentifier, cchSize, stIdentifier);
68 daniel-mar 39
end;
40
 
69 daniel-mar 41
function PluginNameW(lpPluginName: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
68 daniel-mar 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';
69 daniel-mar 51
  result := UD2_WritePascalStringToPointerW(lpPluginName, cchSize, stPluginName);
68 daniel-mar 52
end;
53
 
69 daniel-mar 54
function PluginVendorW(lpPluginVendor: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
68 daniel-mar 55
begin
69 daniel-mar 56
  result := UD2_WritePascalStringToPointerW(lpPluginVendor, cchSize, 'ViaThinkSoft');
68 daniel-mar 57
end;
58
 
69 daniel-mar 59
function PluginVersionW(lpPluginVersion: LPWSTR; cchSize: DWORD; wLangID: LANGID): UD2_STATUS; cdecl;
68 daniel-mar 60
begin
69 daniel-mar 61
  result := UD2_WritePascalStringToPointerW(lpPluginVersion, cchSize, '1.0');
68 daniel-mar 62
end;
63
 
69 daniel-mar 64
function IdentificationMethodNameW(lpIdentificationMethodName: LPWSTR; cchSize: DWORD): UD2_STATUS; cdecl;
68 daniel-mar 65
var
66
  stIdentificationMethodName: WideString;
67
begin
68
  stIdentificationMethodName := 'ComputerName';
69 daniel-mar 69
  result := UD2_WritePascalStringToPointerW(lpIdentificationMethodName, cchSize, stIdentificationMethodName);
68 daniel-mar 70
end;
71
 
69 daniel-mar 72
function CheckLicense(lpReserved: LPVOID): UD2_STATUS; cdecl;
68 daniel-mar 73
begin
69 daniel-mar 74
  result := UD2_STATUS_OK_LICENSED;
68 daniel-mar 75
end;
76
 
70 daniel-mar 77
function DescribeOwnStatusCodeW(lpErrorDescription: LPWSTR; cchSize: DWORD; statusCode: UD2_STATUS; wLangID: LANGID): BOOL; cdecl;
78
begin
79
  // This function does not use non-generic status codes
80
  result := FALSE;
81
end;
82
 
68 daniel-mar 83
exports
84
  PluginInterfaceID         name mnPluginInterfaceID,
85
  PluginIdentifier          name mnPluginIdentifier,
86
  PluginNameW               name mnPluginNameW,
87
  PluginVendorW             name mnPluginVendorW,
88
  PluginVersionW            name mnPluginVersionW,
89
  IdentificationMethodNameW name mnIdentificationMethodNameW,
90
  IdentificationStringW     name mnIdentificationStringW,
70 daniel-mar 91
  CheckLicense              name mnCheckLicense,
92
  DescribeOwnStatusCodeW    name mnDescribeOwnStatusCodeW;
68 daniel-mar 93
 
94
end.