本人有一个Delphi写COM+的组件,以供ASP调用的问题,请各位大侠多多帮忙。(200分)

  • 主题发起人 主题发起人 semman
  • 开始时间 开始时间
S

semman

Unregistered / Unconfirmed
GUEST, unregistred user!
本人要用Delphi写一个COM+的组件,以供ASP调用,但我写的组件可以被Delphi调用,但不能被ASP调用。
程序例子片段如下,
Type Library:

const
// TypeLibrary Major and minor versions
TestComMajorVersion = 1;
TestComMinorVersion = 0;

LIBID_TestCom: TGUID = '{8C4B82C5-8C7B-4E67-A9D3-CB66E1E49960}';

IID_ISimple: TGUID = '{34A3857E-6896-4ADE-A894-082AB2AD0E99}';
CLASS_Simple: TGUID = '{D213FCD5-B3F3-4ED9-95A8-CC4C9E8D712D}';
type
ISimple = interface;
Simple = ISimple;

ISimple = interface(IUnknown)
['{34A3857E-6896-4ADE-A894-082AB2AD0E99}']
function Get_Name(out Value: OleVariant): HResult; stdcall;
end;


Unit:

unit Unit1;

interface

uses
Windows, ActiveX, Classes, ComObj, TestCom_TLB, StdVcl;

type
TSimple = class(TTypedComObject, ISimple)
protected
function Get_Name(out Value: OleVariant): HResult; stdcall;
{Declare ISimple methods here}
end;

implementation

uses ComServ;

function TSimple.Get_Name(out Value: OleVariant): HResult;
begin
Value := 'Hello World!';
end;

initialization
TTypedComObjectFactory.Create(ComServer, TSimple, Class_Simple,
ciMultiInstance, tmApartment);
end.

请各位大侠多多帮忙。
 
理论上讲只要在ASP那部机有注册就可以调用的。
server.CreateObject("Library.ISimple")
 
我写的asp组件
http://www.pctops.net/soft/project1.rar
iis5,iis6测试成功!
 
To:sgzc
我也是这样做的,但是不是提示找不到ProgID,就是提示找不到方法
 
用server.CreateObject("Project1.ImageText")肯定行。
 
To:pctops
可否把你的Delphi源程序给我参考一个,还可以加分,在我谢谢了
 
大家多多帮忙,本人急
 
把你的源程序贴出来,还有你是用IIS几,什么操作系统。
 
我用的是IIS5,操作系统是WINDOWS2000。
源程序如下

TestCom.dpr
library TestCom;

uses
ComServ,
TestCom_TLB in 'TestCom_TLB.pas',
Unit1 in 'Unit1.pas' {Simple: CoClass};

exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;

{$R *.TLB}

{$R *.RES}

begin
end.


TestCom_TLB.pas

unit TestCom_TLB;

interface

uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL;

const
// TypeLibrary Major and minor versions
TestComMajorVersion = 1;
TestComMinorVersion = 0;

LIBID_TestCom: TGUID = '{8C4B82C5-8C7B-4E67-A9D3-CB66E1E49960}';

IID_ISimple: TGUID = '{34A3857E-6896-4ADE-A894-082AB2AD0E99}';
CLASS_Simple: TGUID = '{D213FCD5-B3F3-4ED9-95A8-CC4C9E8D712D}';
type

ISimple = interface;

Simple = ISimple;

ISimple = interface(IUnknown)
['{34A3857E-6896-4ADE-A894-082AB2AD0E99}']
function Get_Name(out Value: OleVariant): HResult; stdcall;
end;

CoSimple = class
class function Create: ISimple;
class function CreateRemote(const MachineName: string): ISimple;
end;

implementation

uses ComObj;

class function CoSimple.Create: ISimple;
begin
Result := CreateComObject(CLASS_Simple) as ISimple;
end;

class function CoSimple.CreateRemote(const MachineName: string): ISimple;
begin
Result := CreateRemoteComObject(MachineName, CLASS_Simple) as ISimple;
end;

end.



Unit1.pas

unit Unit1;

interface

uses
Windows, ActiveX, Classes, ComObj, TestCom_TLB, StdVcl;

type
TSimple = class(TTypedComObject, ISimple)
protected
function Get_Name(out Value: OleVariant): HResult; stdcall;
{Declare ISimple methods here}
end;

implementation

uses ComServ;

function TSimple.Get_Name(out Value: OleVariant): HResult;
begin
Value := 'Hello World!';
end;

initialization
TTypedComObjectFactory.Create(ComServer, TSimple, Class_Simple,
ciMultiInstance, tmApartment);
end.
 
大家多多帮忙,本人急
 
你确认你的IIS用户有足够的权限使用你的Com+组件吗?,如果不能请为你的Com+组件指定一个用户。
 
多人接受答案了。
 
后退
顶部