Autor Beitrag
Apo95
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129

Win2000, WinXP, WinServer 2003 Standard x86, Win7x64
Delphi 6 Enterprise, D2009 Architect, RAD Studio XE6 Architect
BeitragVerfasst: Fr 21.06.13 00:59 
Hi,

anscheinend bin ich zu dämlich oder habe mein Gedächtnis verlegt... (Wäre ja nicht das erste mal) :-/ Ich kriege beim kompilieren folgende Fehlermeldung:

'Ungenügende Forward- oder External-Deklaration' gleich 3x :-(

Hier der Quellcode:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
unit Unit4;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, IniFiles;

type
  TAboutBox = class(TForm)
    Panel1: TPanel;
    ProgramIcon: TImage;
    ProductName: TLabel;
    Version: TLabel;
    Copyright: TLabel;
    Comments: TLabel;
    LizenzLabel: TLabel;
    KeyLabel: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    procedure Panel1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);

function IsAdmin: Boolean;
function GetBiosDate: string;
function CalcCPUSpeed: Extended;

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  AboutBox: TAboutBox;
  ini : TIniFile;
  Date : TDate;

implementation

{$R *.dfm}

procedure TAboutBox.FormCreate(Sender: TObject);
begin
//Werte ermitteln
Label2.Caption := FloatToStr(CalcCPUSpeed);

//Datei wird gesucht; wenn vorhanden :

  if FileExists('C:\Settings\License.lic')=TRUE then
  begin
    ini := TIniFile.Create('C:\Settings\License.lic');
  try
   ini.ReadString('Data','Lizenznehmer',LizenzLabel.Caption);
   ini.ReadString('Data','Key',KeyLabel.Caption);
   ini.ReadString('Data','Apotheke',Label1.Caption);
  finally
  ini.Free;
  end;
  end else begin        //Sollte Datei nicht vorhanden sein

  if  Application.MessageBox('Das Programm war nicht in der Lage, eine gültige Lizenz zu erkennen.'+
    #13+#10+''+
    #13+#10+'Möglicherweise ist die Datei nicht vorhanden, oder ist beschädigt. Expandieren Sie die' +
    #13+#10+'erforderliche Datei über die Kommandozeile und/oder die Graphik von der CD/DVD in das '+
    #13+#10+'entsprechende Verzeichnis. Eine LOG-Datei wird erzeugt.','Ungültige oder beschädigte Lizenz',MB_ICONERROR or mb_OK)=IDOK
    then
    ini := TIniFile.Create('C:\BtM-Dienst\var\'+DateToStr(Date)+'.log');
    try
     ini.WriteString('GENERAL','KERNEL','');
     ini.WriteString('General','WINVER','');
     ini.WriteString('PC_INFO','CPUSpeed','');
     ini.WriteString('PC_INFO','BIOS_Date','');
     ini.WriteString('UAC','IsAdmin','');

    finally
     ini.Free;
  end;
  end;
end;

procedure TAboutBox.Panel1Click(Sender: TObject);
begin
  close;
end;

//Auf root-Rechte überprüfen

function IsAdmin: Boolean;
const
  SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority =
  (Value: (000005));
  SECURITY_BUILTIN_DOMAIN_RID = $00000020;
  DOMAIN_ALIAS_RID_ADMINS     = $00000220;

var
  hAccessToken: THandle;
  ptgGroups: PTokenGroups;
  dwInfoBufferSize: DWORD;
  psidAdministrators: PSID;
  x: Integer;
  bSuccess: BOOL;
begin
  Result := False;
  bSuccess:=False;
  ptgGroups:=nil;
  psidAdministrators:=nil;
  try
    bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True,
      hAccessToken);
    if not bSuccess then
    begin
      if GetLastError = ERROR_NO_TOKEN then
      bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY,
        hAccessToken);
    end;
    if bSuccess then
    begin
      GetMem(ptgGroups, 1024);
      bSuccess := GetTokenInformation(hAccessToken, TokenGroups,
        ptgGroups, 1024, dwInfoBufferSize);
      if bSuccess then
      begin
        AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2,
          SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
          000000, psidAdministrators);
        {$R-}
        for x := 0 to ptgGroups.GroupCount - 1 do
          if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then
          begin
            Result := True;
            Break;
          end;
        {$R+}
      end;
    end;
  finally
    if bSuccess then
      CloseHandle(hAccessToken);
    if Assigned(ptgGroups) then
      FreeMem(ptgGroups);
    if Assigned(psidAdministrators) then
      FreeSid(psidAdministrators);
  end;
end;

//BIOS-Datum ermitteln für LOG

function GetBiosDate: string;
  function SegOfsToLinear(Segment, Offset: Word): Integer;
  begin
    result := (Segment shl 4or Offset;
  end;
begin
  result := string(PChar(Ptr(SegOfsToLinear($F000$FFF5))));
end;

//Methode liest nicht die CPU speed heraus, sondern berechnet diese.
//Es können Abweichnungen auftreten !

function CalcCPUSpeed: Extended;
const
  DelayTime = 500// measure time in ms
var
  TimerHi, TimerLo: DWord;
  PriorityClass, Priority: Integer;
begin
  try
    PriorityClass := GetPriorityClass(GetCurrentProcess);
    Priority := GetThreadPriority(GetCurrentThread);

    SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
    SetThreadPriority(GetCurrentThread,
                      THREAD_PRIORITY_TIME_CRITICAL);
    try
      Sleep(10);
      asm
        dw 310Fh // rdtsc
        mov TimerLo, eax
        mov TimerHi, edx
      end;
      Sleep(DelayTime);
      asm
        dw 310Fh // rdtsc
        sub eax, TimerLo
        sbb edx, TimerHi
        mov TimerLo, eax
        mov TimerHi, edx
      end;
    finally
      SetThreadPriority(GetCurrentThread, Priority);
      SetPriorityClass(GetCurrentProcess, PriorityClass);
    end;
    Result := TimerLo / (1000.0 * DelayTime);
  except
    Result := 0;
  end;

end;


Was die Fehlermeldung bedeutet, weiß ich zwar; kann den Fehler aber nicht beheben...

_________________
Lette-Verein MIA
MeierZwoo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 94
Erhaltene Danke: 11

Win 7, DOS5
Delphi 2007 Architect, BP7/TP5, LISP, PS
BeitragVerfasst: Fr 21.06.13 01:59 
Müßte es nicht

function TAboutBox.GetBiosDate: string;
..
end;

function TAboutBox.CalcCPUSpeed: Extended;
..
end;

function TAboutBox.IsAdmin: Boolean;
..
end;

heißen?
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Fr 21.06.13 08:23 
Japp, müsste es, was bei korrekter Einrückung auch sofort ins Auge gefallen wäre ;) Eine Methode und eine "reguläre" Routine sind nun einmal 2 Paar Schuhe.

[edit] Tipp: die Klassenvervollständigung nutzen, damit passiert so etwas dann nicht. [/edit]
Blup
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 174
Erhaltene Danke: 43



BeitragVerfasst: Fr 21.06.13 14:49 
Unabhängig von dem aktuellen Problem als Hinweis:
user profile iconApo95 hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  AboutBox: TAboutBox;
  ini : TIniFile;
  Date : TDate;

Variablen-Deklarationen gehören in die jeweilige Methode oder in den Abschnitt private der Klasse.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
// falsch: if FileExists('C:\Settings\License.lic')=TRUE then
// richtig:
 if FileExists('C:\Settings\License.lic'then
// oder überflüssig aber nicht falsch:
 if FileExists('C:\Settings\License.lic') <> FALSE then

Niemals mit der Konstanten "TRUE" vergleichen.
True ist eigentlich "not FALSE", als Konstante wird aber je nach Programmiersprache 1 (Delphi) oder -1 definiert.
Wenn die Funktion das Ergebnis z.B. aus einer DLL erhält, kann als Ergebnis auch -1 sein.