ASP component primary entry and exquisite series eight

xiaoxiao2021-03-06  117

Let's make a component, one that can generate the GUID component

Global Same Sign (GUID)

A GUID can represent 32 characters of hexadecimal format. COM provides a system-level function called CocreateGUID, which can be used to generate new GUID. This function relies on an algorithm similar to using information such as a single marker and system clock using a computer network card to create a unique GUID in time and space.

Open VB6, create a new ActiveX DLL project. The engineering name is modified to FCOM, and the class name is modified to FC8

Option expedition

Private Type GUID

Data1 As Long

Data2 as long

Data3 as long

Data4 (8) as Byte

End Type

Private Declare Function Cocreateguid Lib "Ole32.dll" (Pguid As GUID) AS Long

Private Declare Function StringFromGUID2 LIB "Ole32.dll" (RGUID As Any, Byval LPSTRCLSID AS Long, Byval CBMAX AS Long) As long

'Take the GUID code

'parameter:

'Return Value: String, a GUID code.

Public function getGuidcode () AS String

DIM UGUID AS GUID

DIM SGUID AS STRING

DIM BGUID () AS BYTE

Dim llen as long

DIM RETVAL AS Long

Llen = 40

Bguid = String (Llen, 0)

CoCreateGuid UGUID 'converts the structure into a displayable string

Retval = StringFromGuid2 (UGUID, Varptr (bguid (0)), LLEN

Sguid = BGUID

IF (ASC (MID $ (SGUID, RETVAL, 1)) = 0) THEN RETVAL = RETVAL - 1

GetGuidcode = Left $ (SGUID, RETVAL)

END FUNCTION

OK, a component is written, click on the menu -> File -> Generate the FCOM.dll file

Determine, there will be an FCOM.dll file in the directory.

test

Open Visual InterDev6.0 to generate an ASP file

<% @ Language = VBScript%>

<%

DIM OBJ

Set obj = server.createObject ("fcom.fc8")

Response.write obj.getGuidcode ()

Response.write "
"

Response.write obj.getGuidcode ()

%>

Configure a virtual directory, perform this ASP file in IE, resulting in the following:

{EF7BF6F9-564C-44D9-91BF-F31695DA6298} {C8A68CAC-A108-45A6-84F5-0BF92B9CF721}

You can refresh multiple times, you can see this value is constantly changing.

转载请注明原文地址:https://www.9cbs.com/read-125640.html

New Post(0)