首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

用Delphi7开发了个ASP定时组件不能用,why

2012-03-08 
【求助】用Delphi7开发了个ASP定时组件不能用,why?高手请进我用Delphi7开发了个ASP定时组件代码如下:unitMai

【求助】用Delphi7开发了个ASP定时组件不能用,why?高手请进
我用Delphi7开发了个ASP定时组件代码如下:
unit   Main;

{$WARN   SYMBOL_PLATFORM   OFF}

interface

uses
    Windows,Dialogs,ComObj,   ActiveX,   AspTlb,   Timer_TLB,   StdVcl;

type
    Tsleep   =   class(TASPObject,   Isleep)
    private
        st:Longint;
        proc:TFarProc;
        lhnd:THandle;
    protected
        procedure   OnEndPage;   safecall;
        procedure   OnStartPage(const   AScriptingContext:   IUnknown);   safecall;
        function   Get_stime:   Integer;   safecall;
        procedure   Set_stime(Value:   Integer);   safecall;
        procedure   SleepTime;   safecall;
    end;

implementation

uses   ComServ;
type
    TSleeps   =   procedure(dwMilliseconds:WORD);stdcall;//dwMilliseconds   sleep   time   in   milliseconds
var
    ts:TSleeps;
procedure   Tsleep.OnEndPage;
begin
    inherited   OnEndPage;
end;

procedure   Tsleep.OnStartPage(const   AScriptingContext:   IUnknown);
begin
    inherited   OnStartPage(AScriptingContext);
end;

function   Tsleep.Get_stime:   Integer;
begin
        Result:=st;
end;

procedure   Tsleep.Set_stime(Value:   Integer);
begin
        st:=Value;
end;

procedure   Tsleep.SleepTime;
begin
      lhnd:=LoadLibrary( 'kernel32.dll ');
    if   lhnd> 0   then
    begin
    try
    proc:=GetProcAddress(lhnd,Pchar( 'Sleep '));
    if   proc <> nil   then
    begin
    ts:=TSleeps(proc);
    ts(st);
    end
    else
    ShowMessage( '函数没有找到 ');
    finally
    FreeLibrary(lhnd);
    end//end   try
    end
    else
    begin
        ShowMessage( 'dll没找到 ');
    end;
end;

initialization
    TAutoObjectFactory.Create(ComServer,   Tsleep,   Class_sleep,
        ciMultiInstance,   tmApartment);
end.
在ASP中的代码如下:
<HTML>
<BODY>
<TITLE>   Testing   Delphi   ASP   </TITLE>
<CENTER>
<H2>   Timer测试   </H2>
</CENTER>
<HR>
<%   Set   DelphiASPObj   =   Server.CreateObject( "Timer.sleep ")
      DelphiASPObj.stime=3000
      response.write   DelphiASPObj.stime& " <br> <br> "
      DelphiASPObj.SleepTime
      response.write   DelphiASPObj.stime& " <br> <br> "
      DelphiASPObj.SleepTime
      response.write   DelphiASPObj.stime& " <br> <br> "
      DelphiASPObj.SleepTime    


      Set   DelphiASPObj   =nothing
%>
<HR>
</BODY>
</HTML>
但是ASP页面根本就显示不出来,请教如何解决?怎么样可以让属性值被定期读出?在线等待答案……………………………………

[解决办法]
帮顶
[解决办法]
帮你顶起来

热点排行