Application techniques for invoking DCOM components in ASP

Source: Internet
Author: User

Application techniques for invoking DCOM components in ASP

1. Write DCOM components:

Suppose we want to remotely start the DNS service through an ASP page, and the DNS server is not the same machine as the Web server. We can write an ActiveX DLL to implement this functionality.

First we set up a batch file Startdns.bat, written in the file: Net Start DNS. Save the file in a directory of the DNS server, such as C:\ManDNS\:

Secondly, we write the DLL program as follows (VB writing):

Public Function Startdns () as Boolean

On Error GoTo Errhandle

Dim Strreturn Strreturn = Shell ("C:\ManDNS\StartDNS.bat")

Startdns = True

Exit Function Errhandle:startdns = False

End Function

The DLL name is called the Mandns class named Dnsclass we save this DLL under C:\ManDNS\.

2, register the DCOM component:

After writing the DLL program, we will register it on the server.

First open Microsoft Transaction Server on the DNS server, click Computers, click My Computer, select Packages installed, click the right mouse button, select New, and then click Package. Will pop up package Wizard. Select the Hollow bag, named Mandns, to determine the completion. Click to open this package, select Component, right-click, select New--->component. Click Import Component that Are already, select ManDNS.Dll in the list box.

Then open Microsoft Transaction Server on the Web server, click Computers, point to remote Computer, select Mandns Component on the DNS server, and click OK to join the Web server.

3. Invoke the DCOM component:

Write startdns.asp and invoke the registered DCOM component in it, as follows:

〈%@ language= "VBSCRIPT"%>

〈html>

〈head>

〈title>

Start DNS Page

〈/title>

〈head>

〈body>

〈h1> Click the button to start the DNS service 〈/h1>

〈 %

If Request.Form ("click") 〈> "" Then

Dim Startdns, Renstart

Set Startdns = Server.CreateObject ("Startdns.dnsclass")

Renstart = Startdns. Startdns

If Renstart Then

Response.Write The DNS service started successfully. ”

Else

Response.Write The DNS service failed to start. ”

End If

End If

%>

〈form action = "startdns.asp" method = "Post" >

〈input type = Submit Name = Submit Value = "Start DNS" >

〈input type = hidden name = Click value = "click" >

〈/form>

〈/body>

〈/html>

For programmers, you can use your familiar programming tools to write ActiveX DLLs, manage them with MTS, and use an ASP program to build systems that are reasonably capable of making all kinds of components available on the Internet.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.