How to call DLL in ASP file
Dynamic link library (DLL) is an important method to speed up the execution of key parts of the application, but there is one thing that most people may not know, that is, the ASP file can also be called by calling the DLL. To speed up the execution of the server, let me briefly introduce the steps of calling DLL in the ASP file.
First, there must be a DLL file. In this example, an ActiveX DLL file is created through VB5.0. This file simulates a process of throwing dice.
In the VB5.0 environment, create a new project and double-click the ActiveX DLL icon in the new project window. VB will automatically add a class module to the project and set the project type to ActiveX DLL. In the Properties window, change the name attribute of the class module to clsDice. From the Project menu, select Project Properties and change the project name to MyDLL. From the File menu, choose Save clsDice to save the class module as myDice.cls. Add the following code:
Option Explicit
Private Max, Point As Integer
Public Property Get Result() As Integer
Result = Point
End Property
Public Property Get Maxpoint() As Integer
Maxpoint = Max
End Property
Public Property Let Maxpoint(num As Integer )
Max = num
End Property
Public Sub Throw()
Randomize
Point = Int(Rnd * Max) + 1
End Sub
Private Sub Class_Initialize()
Max = 6
End Sub
This class module defines clsDice Object has two properties and one method. These properties and methods simulate the process of throwing dice. Among them, the Maxpoint attribute represents the number of faces of the dice. Adding the Property Let statement will enable the customer to modify the number of faces of the dice; the Result attribute represents the final number of points of the dice; the Throw method represents the action of throwing the dice; the Private Sub Class_Initialize statement will The number of sides of the child is set to 6 by default.
From the File menu, choose Generate MYDLL.DLL and save it to the appropriate location. At this point, we have created our own DLL file.
The second step is to reference the class clsDice in the ASP file.
All codes of ASP (Active Server Pages) are run on the server, and customers can only view the results returned in HTML form. It uses "<%" and "%>" tags to identify script code and does not pass it back to the client. Outside the code, HTML tags are used to identify content. In the code of Dice.asp below, the CreateObject function is used to create a clsDice object instance, which comes from the ActiveX.DLL--MYDLL.DLL file created above, as follows The examples use the VBScript scripting language.
'Load the type library specified in the METADATA tag. Path is the path where mydll.dll is stored on the machine
##
<%
On Error Resume Next 'The program can continue to execute when an unexpected error occurs
If Request.Form(" T1")="" then
Session("point") = 6
Else
Session("point")=Request.Form("T1")
End If
'Use Session("point") to store the number of dice faces
Set dice1=Server.Createobject("MyDLL.clsDice")
'Use the set statement to create the dice1 object, where MyDLL is the project name when the dll file was created above (note: not the name of the file), and clsDice is the name of the class module. At this point we can use Maxpoint, Result and Throw attributes (methods) to operate on the dice1 object.
If Request.ServerVariables("Request_Method")="POST" then
dice1.Maxpoint = Session("point") 'Set the number of sides of the dice
dice1.Throw 'Throw dice
%>
The result is: <% = dice1.Result %>Point
'Return result<%
Else
dice1 .Maxpoint = Session("point")
%>
<%
End If
%>
The above code is in WINDOWS NT4.0 +SP3+IIS4.0+IE5.0+VB5.0 compiled and ran successfully, but there are still many defects. However, my original intention was to introduce you to how to call DLL in ASP, so I did not improve it.
The above is the detailed content of How to call DLL in ASP file. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



If Nvgpucomp64.dll is causing your game to crash frequently, the solutions provided here may help you. This problem is usually caused by outdated or corrupted graphics card drivers, corrupted game files, etc. Fixing these issues can help you deal with game crashes. The Nvgpucomp64.dll file is associated with NVIDIA graphics cards. When this file crashes, your game will crash too. This usually happens in games like LordsoftheFallen, LiesofP, RocketLeague, and ApexLegends. Nvgpucomp64.dll crashes games on Windows PC if N

Many users will be prompted that coremessaging.dll is missing when using their computers to play games. I believe that many users will immediately think that there is a problem with the software or the game. In fact, it is not. This is because the computer is missing the dll file. , users can download the coremessaging.dll file. Let this site carefully introduce to users the analysis of the problem that the CoreMessaging.dll file in the Windows system directory is missing and cannot be found. Analysis of the problem that the CoreMessaging.dll file in the Windows system directory is missing and cannot be found 1. Download the CoreMessaging.dll file 2.

How to solve the problem of missing libcurl.dll in win7 system? Generally, dll files will cause some programs to be unable to be used normally. Faced with this problem, many users do not know how to solve it. In response to this situation, today the editor will share a detailed solution with the majority of users. I hope that win7 will be used today. Tutorials can help a large number of users, so let’s take a look. Solution to missing libcurl.dll in win7 system 1. Download the libcurl.dll file. 2. After downloading, put the file into the corresponding folder. The paths for 32-bit and 64-bit operating systems are as follows: For 32-bit Win7 operating system, copy the file directly to C:\Windows\SYSTEM32

Many users like to use computers to play games. Recently, some users of Win7 system have reported that when starting the game, they encountered a pop-up window prompting that the Skidrow.dll file is missing in the computer and cannot be started. The game cannot be loaded normally. What is going on? ? In response to this problem, this article brings a detailed solution to share with everyone, let’s take a look. What to do if Win7 prompts that Skidrow.dll is missing from the computer when starting the game? 1. Download the Skidrow.dll file. 2. Unzip the folder and copy the Skidrow.dll file to the system directory. 32-bit systems: C:\WINNT\System 324-bit systems: C:\Windows\SysWOW

vcruntime140_1.dll is a component of the Visual C runtime library. Many users have encountered the error that vcruntime140_1.dll cannot continue to execute code when using Microsoft Visual Studio for development. So what should users do if they encounter this problem? Let this site carefully introduce to users how to solve the problem that vcruntime140_1.dll cannot continue to execute code. Reasons why vcruntime140_1.dll is lost Uninstalling the VisualC runtime library: Misoperation or upgrading VisualC results in the runtime library being lost. Virus infection: Malware deletes or damages vc

Solution: 1. Re-download or obtain the DLL file from a reliable source; 2. Check the dependencies of the DLL file; 3. Make sure you are using the correct DLL version; 4. Register the DLL file; 5. Check the firewall and security software settings ; 6. Contact the software supplier or technical support.

Master Lu is a hardware detection tool used by many users. Detailed hardware information can be viewed through the software, but it has many functions that can repair multiple drivers. Many people want to know whether Master Lu can repair dll files? How to fix it? Regarding this problem, the editor of this software tutorial will explain it to you. Friends who want to know more are welcome to check it out. Tutorial on Master Lu’s one-click repair of all missing DLLs: 1. First open Master Lu and enter the main interface. 2. Next, click the game library in the upper right corner, and then click Repair in the upper right corner. 3. The last step is to repair the missing dll file.

What kind of file is VCRUNTIME140.dll? Why does the computer lose VCRUNTIME140.dll when running some games, and then the game fails to run? This dll file is an important runtime library file of the computer. If it is lost, many programs will not be able to run. What is VCRUNTIME140.dll? It is one of the files in the VC++2015 runtime library. 1. VCRUNTIME140.dll is an important file necessary for the operation of Microsoft windows system. 2. Different programs in the computer require different dll files to support their operation. 3. When the computer is running the program, a message indicating that the VCRUNTIME140.dll file is missing appears.
