源码改错(sorry,分用完了)(0分)

  • 主题发起人 主题发起人 it2188
  • 开始时间 开始时间
I

it2188

Unregistered / Unconfirmed
GUEST, unregistred user!
写成的dll中带有调用了TNMUUProcessor控件,编译通过,调用该dll时,出错?
如何修改?这个dll的用途是输入一个base64编码的文件名,生成解码的文件。
出现警告:[Warning] Unit1.pas(34): Variable 'base64' might not have been initialized
源代码:
unit Unit1;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
ComObj, ActiveX, AspTlb, maildebase64_TLB, StdVcl,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Dialogs, StdCtrls,NMUUE;

type
Tdebase64 = class(TASPMTSObject, Idebase64)
private
infile:string;
protected
procedure debase; safecall;
procedure Set_emlname(const Value: WideString); safecall;
end;

implementation

uses ComServ,Unit2;

procedure Tdebase64.debase;
var
outfile:string;
InStream,OutStream: TFileStream;
base64:TNMUUProcessor;
begin
outfile:=infile+'txt';
InStream := TFileStream.Create(infile, fmOpenRead);
OutStream := TFileStream.Create(outfile, fmCreate);
try
base64.Create(nil);
base64.Method:=uuMIME;
base64.InputStream:=InStream;
base64.OutputStream:=OutStream;
base64.Decode;
finally
InStream.Free;
OutStream.Free;
base64.Free;
end;
end;

procedure Tdebase64.Set_emlname(const Value: WideString);
begin
infile:=vartostr(Value);
end;

initialization
TAutoObjectFactory.Create(ComServer, Tdebase64, Class_debase64,
ciMultiInstance, tmApartment);
end.
 
unit Unit2;

interface

uses
SysUtils, Classes, NMUUE;

type
TDataModule2 = class(TDataModule)
NMUUProcessor1: TNMUUProcessor;
private
{ Private declarations }
public
{ Public declarations }
end;

var
DataModule2: TDataModule2;

implementation

{$R *.dfm}

end.
 
试试:


try
base64.Create(nil);
new(base64); //<<<
base64.Method:=uuMIME;
base64.InputStream:=InStream;
base64.OutputStream:=OutStream;
base64.Decode;
finally
InStream.Free;
OutStream.Free;
base64.Free;
end;
 
amsea:在new(base64);出错:
[Error] Unit1.pas(35): Incompatible types
[Fatal Error] maildebase64.dpr(9): Could not compile used unit 'Unit1.pas'
 
base64 := TNMUUProcessor.Creaet(nil)
try
// base64.Create(nil);
base64.Method:=uuMIME;
base64.InputStream:=InStream;
base64.OutputStream:=OutStream;
base64.Decode;
finally
InStream.Free;
OutStream.Free;
base64.Free;
end;
 
后退
顶部