-
Здраствуйте, я работаю в Delphi 2007 CodeGear RAD Studio, и там столкнулся с проблеммой при создании COM сервера не сохраняется .tlb файл, пишет - Unable to rename 'C:\..\comserver.tlb..' to '' , вследствии чего и не компилируется программа, подскажите в чём проблемма, в delphi 7 всё работает...?
-
не сохраняя открыл закрыл, компилится, но при подключении выдаёт ошибку
'Interface not supported'
Код сервера:unit comS;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, ActiveX, Classes, ComObj, serv07_TLB, StdVcl;
type
TtestCom07 = class(TTypedComObject, ItestCom07)
protected
function Method1(out f: OleVariant): HResult; stdcall;
{Declare ItestCom07 methods here}
end;
implementation
uses ComServ;
function TtestCom07.Method1(out f: OleVariant): HResult;
begin
Result:=s_Ok;
end;
initialization
TTypedComObjectFactory.Create(ComServer, TtestCom07, Class_testCom07,
ciMultiInstance, tmApartment);
end.
unit serv07_TLB;
// ************************************************************************ //
// WARNING
// -------
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// 'Refresh' command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// ************************************************************************ //
// $Rev: 5081 $
// File generated on 05.08.2008 14:26:09 from Type Library described below.
// ************************************************************************ //
// Type Lib: C:\Documents and Settings\Администратор\Рабочий стол\com\New_Test\serv07\serv07.tlb (1)
// LIBID: {F9567FCB-C113-4727-ACC5-46822B2B884B}
// LCID: 0
// Helpfile:
// HelpString: serv07 Library
// DepndLst:
// (1) v2.0 stdole, (C:\WINDOWS\system32\STDOLE2.TLB)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interface
uses Windows, ActiveX, Classes, Graphics, StdVCL, Variants;
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:
// Type Libraries : LIBID_xxxx
// CoClasses : CLASS_xxxx
// DISPInterfaces : DIID_xxxx
// Non-DISP interfaces: IID_xxxx
// *********************************************************************//
const
// TypeLibrary Major and minor versions
serv07MajorVersion = 1;
serv07MinorVersion = 0;
LIBID_serv07: TGUID = '{F9567FCB-C113-4727-ACC5-46822B2B884B}';
IID_ItestCom07: TGUID = '{5B276491-AE89-4CB4-8ED9-8EA29D289CE1}';
CLASS_testCom07: TGUID = '{3CD6D218-5DE2-4D35-A81C-053553E21A3A}';
type
// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
ItestCom07 = interface;
// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
testCom07 = ItestCom07;
// *********************************************************************//
// Interface: ItestCom07
// Flags: (256) OleAutomation
// GUID: {5B276491-AE89-4CB4-8ED9-8EA29D289CE1}
// *********************************************************************//
ItestCom07 = interface(IUnknown)
['{5B276491-AE89-4CB4-8ED9-8EA29D289CE1}']
function Method1(out f: OleVariant): HResult; stdcall;
end;
// *********************************************************************//
// The Class CotestCom07 provides a Create and CreateRemote method to
// create instances of the default interface ItestCom07 exposed by
// the CoClass testCom07. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CotestCom07 = class
class function Create: ItestCom07;
class function CreateRemote(const MachineName: string): ItestCom07;
end;
implementation
uses ComObj;
class function CotestCom07.Create: ItestCom07;
begin
Result := CreateComObject(CLASS_testCom07) as ItestCom07;
end;
class function CotestCom07.CreateRemote(const MachineName: string): ItestCom07;
begin
Result := CreateRemoteComObject(MachineName, CLASS_testCom07) as ItestCom07;
end;
end.
Клиент:
unit cl07;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,serv07_TLB;
type
TForm3 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
Fase:ItestCom07;
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
uses ComObj,ActiveX;
procedure TForm3.Button1Click(Sender: TObject);
begin
Fase:= CotestCom07.Create;
end;
procedure TForm3.Button2Click(Sender: TObject);
var ol:OleVariant;
begin
Fase.Method1(ol);
end;
//
procedure TForm3.Button3Click(Sender: TObject);
begin
try
Fase := CreateComObject(CLASS_testCom07) as ItestCom07;
except
MessageDlg( 'nenenenee!!!', mtError, [mbOk], 0);
end;
end;
end.
Подскажите в чём дело? -
tesseract © (05.08.08 12:57) [2]Возможно файл занятдругим приложением. А зачем его переименовывать ?
-
да не его и не надо переименовывать, просто делфи при сохранении выдаёт такую ошибку, и файл при чём не занят другим приложением
ответ оказывается - http://www.delphikingdom.ru/asp/answer.asp?IDAnswer=56132