调用单元的问题!!!(10分)

  • 主题发起人 主题发起人 taozhiyu
  • 开始时间 开始时间
T

taozhiyu

Unregistered / Unconfirmed
GUEST, unregistred user!
以下GlobeFunction被MainForm和ImageForm调用。在编译的时候出现
错误:"[Error] GlobeFunction.pas(10): Unsatisfied forward or external declaration: 'TReg.WriteRegistry'
[Error] GlobeFunction.pas(11): Unsatisfied forward or external declaration: 'TReg.ReadRegistry'
[Fatal Error] setitem.pas(42): Could not compile used unit 'GlobeFunction.pas'
"
请问这是什么问题啊????


unit GlobeFunction;

interface

uses Registry, Windows;

type
TReg = class
public
function WriteRegistry(Name,Value:string):boolean;
function ReadRegistry(Name:string):String;
end;

implementation

function WriteRegistry(Name,Value:string):boolean;
var
registerTemp : TRegistry;
// HKEY_LOCAL_MACHINE : HKEY;
begin
registerTemp := TRegistry.Create;
with registerTemp do
begin
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('Software/ASoft',true) then
begin
WriteString(Name,Value);
result := true;
end
else result := false;
CloseKey;
Free;
end;
end;

function ReadRegistry(Name:string):String;
var
RegisterTemp : TRegistry;
begin
RegisterTemp := TRegistry.Create;
RegisterTemp.RootKey := HKEY_LOCAL_MACHINE;
RegisterTemp.OpenKey('Software/ASoft',false);
result := RegisterTemp.ReadString(Name);
//RegisterTemp.CloseKey;
RegisterTemp.Free;
end;

end.
 
在Function要加TReg.
unit GlobeFunction;

interface

uses Registry, Windows;

type
TReg = class
public
function WriteRegistry(Name,Value:string):boolean;
function ReadRegistry(Name:string):String;
end;

implementation

function TReg.WriteRegistry(Name,Value:string):boolean;
var
registerTemp : TRegistry;
// HKEY_LOCAL_MACHINE : HKEY;
begin
registerTemp := TRegistry.Create;
with registerTemp do
begin
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('Software/ASoft',true) then
begin
WriteString(Name,Value);
result := true;
end
else result := false;
CloseKey;
Free;
end;
end;

function TReg.ReadRegistry(Name:string):String;
var
RegisterTemp : TRegistry;
begin
RegisterTemp := TRegistry.Create;
RegisterTemp.RootKey := HKEY_LOCAL_MACHINE;
RegisterTemp.OpenKey('Software/ASoft',false);
result := RegisterTemp.ReadString(Name);
//RegisterTemp.CloseKey;
RegisterTemp.Free;
end;

end.
 
你的
function WriteRegistry(Name,Value:string):boolean;
function ReadRegistry(Name:string):String;
应该是
function TReg.WriteRegistry(Name,Value:string):boolean;
function TReg.ReadRegistry(Name:string):String;

错误信息就告诉你在TReg类定义中声明了writeRegistry和ReadRegistry,但是
没有实现部分.
 
[^]哦!Thanx!!! [:)]
 
后退
顶部