用c++builder 编写asp 组件

cshadow 2003-09-04 09:40:20
我想用c++builder 编写asp 组件,谁有相关的例子?
请留下url地址或者有文本发给我,谢谢。
email:heli_e@hotmail.com
...全文
51 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
suhuoqiang 2003-12-10
  • 打赏
  • 举报
回复
vb我会..

如果只是这么需要组件来加密的话,,强烈推荐.net/JSP
lqflsh 2003-12-10
  • 打赏
  • 举报
回复
很少遇到哦。我有一个应该是vc的。
online 2003-12-09
  • 打赏
  • 举报
回复
只有delphi的
Creating an ActiveX for ASP
COM libraries for Active Server Pages
Product:Delphi 5.x (or higher)

Uploader: Daniel Wischnewski
Question/Problem/Abstract:

How to create an ActiveX that can be used in Active Server Pages for dynamic content?
Answer:


This article shows you how to create a server-side ActiveX library you can use within ASP (Active Server

Pages). We'll keep it very simple.

CREATING THE ACTIVEX SERVER
===========================

First, start Delphi and/or close all current projects. Select File|New and change to the "ActiveX" tab. Select

the "ActiveX library" project type. AxtiveX libraries, as this can be used for ASP. They are DLL that are

implemented by the Server.CreateObject (VBScript) directive.

An ActiveX library must export 4 routines, allowing it to be un-/registered, export its objects and tell the

calling process whether it may be unloaded. These for four functions are provided through the ComServ unit, by

Borland. You do not have worry about them.

Next, we will create an "Active Server Object". You find these within the File|New dialog on the "ActiveX" tab,

too. You will see a dialog with quite a few options. First we will have to enter CoClass Name. This is the name

we will use when accessing the object from within our ASP page. Let's call it "Sample". Now we have to choose

the "instancing model" and the "threading model". Choose "Single Instance" and "Apartment" from the drop-down

lists. (I will explain these models in another article, later on. Drop me an e-mail if you want me to tell you

when.) For "Active Server Type" choose "Object Context", leave the check mark in the "Generate template..."

check box and press OK.

Delphi will create a new unit (unit1), an ASP (sample.asp), and a type library (project1_tlb). Let's save these

files now. (Choose save all and use the following names: uSample.pas, Sample.asp, First.dpr).

Goto to the menu and select View|Type Library. This window shows all the objects with their methods and

properties within the type library we create. The root object is named "First" (if you've used the same file

names). This is your type library name, it must be unique on the machine it is running. Underneath "First" you

see two more entries (ISample and Sample). One is the public dispatch interface declaration where all methods

and properties are names, the other is the object name that is used within the applications accessing you

ActiveX library.

Select the ISampe entry. In the tool bar you will see a green icon (New Method) and a blue icon (New Property)

to its right. These are the two we are going to check out in this article.

First select new method. A new entry ("Method1) will appear underneath the ISample entry. Change its name to

ShowTime. Select the "Parameters" tab on the right and add a new parameter to the list. Set its name to

"TheTime", the type to "BSTR *". Double-click the modifier with your mouse and select "out" and "retval". The

"in" box will be deselected automatically. It is not working with "retval" together. We have declared the

Parameter "TheTime" as WideString (ASO does not support Pascal Type Strings) as a Return Value. Close the Box

by pressing OK.

Save your project files (!), goto to your editor window and select the uSample unit. Delphi has added the

following method, automatically:
function ShowTime: WideString; safecall;
Since the parameter "TheTime" was declared as Return Value, Delphi created a function with the Result Type

WideString. The safecall directive tells the Delphi Compiler to ensure the proper DLL/COM wrapping for the

function.

Fill out the ShowTime function as follows:

function TSample.ShowTime: WideString;
begin
Result := FormatDateTime(
'"This function was called on " dddd, mmmm d, yyyy, " at " hh:mm AM/PM',
Now
);
end;

That's all for the Delphi code. Save your project and select Run|Register ActiveX Server from your menu. The ActiveX server has to be installed on the machine where it is used. Without Delphi you can do this by calling
regsvr32 "Drive:\Path\FileName.dll"
from the command line. Add the parameter /u to unregister the ActiveX server.

THE ACTIVE SERVER PAGE
======================

Delphi has prepare the Sample.asp file already. we just have to fill in the missing parts.

In our case we have to change the line
DelphiASPObj.{Insert Method name here}
into
Response.Write DelphiASPObj.ShowTime
"Response.Write" tells ASP to write the following text (provided by our function) into the current place of our HTML code.

Copy the sample ASP into your web server directory (/test) and call it like:
http://localhost/test/sample.asp.

You should have installed either the MS Internet Information Server (IIS) or MS Personal Web Server (PWS).
Good luck and stay tuned for more.

Yours,
Daniel
aloxy 2003-12-09
  • 打赏
  • 举报
回复
不会,勾勾去钩一下
wocsdn 2003-12-09
  • 打赏
  • 举报
回复
俺也不会,,谢了,接分
liuvb 2003-12-09
  • 打赏
  • 举报
回复
不会,接分
cshadow 2003-12-09
  • 打赏
  • 举报
回复
请回复下,我要结贴
当散分啦

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧