WinAPI is used in PB to generate a global unique marking code (GUID, UUID)

xiaoxiao2021-03-06  21

1, define structure and external functions

Global Type UUID from Structure Ulong Data1 Uint Data2 Uint Data3 Character Data4 [8] End Type

Function ulong UuidCreate (ref uuid lpUUID) LIBRARY "rpcrt4" Function ulong UuidToString (ref uuid lpUUID, ref long lpUUIDString) LIBRARY "rpcrt4" Alias ​​for "UuidToStringA" Function ulong RpcStringFree (long lpUUIDString) LIBRARY "rpcrt4" Alias ​​for "RpcStringFreeA"

2, function main body

Constant Long RPC_S_OK = 0constant Long RPC_S_UUID_LOCAL_ONLY = 1824

Long ll_rtnuuid ull_rtn = uuidcreate (u) // Create a new UUIDIF ll_rtn = RPC_S_OK OR ll_rtn = RPC_S_UUID_LOCAL_ONLY THEN Long ll_pointer String ls_uuid ll_rtn = UuidToString (u, ll_pointer) ls_uuid = Upper (String (ll_pointer, "Address")) // Convert IT to a string

RPCStringFree // Remove The string from the memory Return Ls_UUIDELSE RETURN "" END IF

Note: RPCRT4.DLL may be needed during posting

Attachment: another method of generating a GUID

oleObject PBOBJECTSTRING LS_GUIDLONG LL_RESULT

PBObject = Create oleobject

ll_result = PBObject.ConnectToNewObject & ( "PowerBuilder.Application") IF ll_result <0 THEN messagebox ( "", "connection failed:! PowerBuilder.Application connection error") Destroy PBObject return "" ELSE ll_result = PBObject.GenerateGUID (REF ls_GUID ) End ifdestroy PBOBJECT

Return MID (LS_GUID, 2, LEN (LS_GUID) - 2)

The second method needs to configure on the client at the time of the program:

PBAPL80.DLLPBAEN80.TLBRPCRT4.DLL

Modify the registry as follows

Windows Registry Editor Version 5.00

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; pbappl.reg ;; registration information for powerbuilder.Application.8 ;; all rights reserved. No portion of this Material May Be copied in any Way; WITHOUT prior Written Consent from PowerSoft Corporation. ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;, ingpenetic

[Hkey_classes_root / powerbuilder.application] @ = "Powerbuilder Automation"

[Hkey_classes_root / powerbuilder.application / clsid] @ = "{8888000-080009ac61a9}"

[HKEY_CLASS_ROOT / POWERBUILDER.Application / Curver] @ = "Powerbuilder.Application.8"

[HKEY_CLASS_ROOT / POWERBUILDER.Application / NotInsertable] @ = ""

; Version Specific Progid Entries [HKEY_CLASS_ROOT / POWERBUILDER.Application.8] @ = "PowerBuilder 8.0 Automation"

[Hkey_classes_root / powerbuilder.Application.8 / clsid] @ = "{8888000-080009ac61a9}"

[HKEY_CLASS_ROOT / POWERBUILDER.Application.8 / NotInsertable] @ = ""

; CLSID Entries [HKEY_CLASES_ROOT / CLSID / {88880001-8888-1000-8000-080009AC61A9}] @ = "Powerbuilder Automation"

[HKEY_CLASSES_ROOT / CLSID / {88880001-8888-1000-8000-080009AC61A9} / InProcServer32] @ = "d: // Program Files // Sybase // Shared // PowerBuilder // pbvm80.dll" "ThreadingModel" = "Apartment"

[Hkey_classes_root / clsid / {88880001-8888-1000-8000-080009AC61A9} / notinsertable] @ = ""

[Hkey_classes_root / clsid / {88880001-8888-1000-8000-080009AC61A9} / progid] @ = "Powerbuilder.Application.8"

[Hkey_classes_root / clsid / {88880001-8888-1000-8000-080009AC61A9} / programmable] @ = ""

[HKEY_CLASSES_ROOT / CLSID / {88880001-8888-1000-8000-080009AC61A9} / TypeLib] @ = "{88880002-8888-1000-8000-080009AC61A9}" [HKEY_CLASSES_ROOT / CLSID / {88880001-8888-1000-8000-080009AC61A9} /Versionindependentprogid]@="powerbuilder.Application

; Type library registration entries [HKEY_CLASES_ROOT / TYPELIB / {88880002-8888-1000-8000-080009AC61A9}]

[HKEY_CLASS_ROOT / TYPELIB / {88880002-8888-1000-8000-080009AC61A9} /1.0] @ = "PowerBuilder Automation Type Library"

[Hkey_classes_root / typeelib / {88880002-8888-1000-8000-080009AC61A9} / 1.0]

[HKEY_CLASS_ROOT / TYPELIB / {88880002-8888-1000-8000-080009AC61A9} / 1.0/0/win32] @ = "D: // Program files // Sybase // Shared // PowerBuilder // PBAEN80.TLB"

[Hkey_classes_root / typelib / {88880002-8888-1000-8000-080009AC61A9} /1.0/9]

[Hkey_classes_root / typelib / {88880002-8888-1000-8000-080009AC61A9} /1.0/9/win32] @ = "d: // program files // sybase // shared // powerbuilder // pbaen80.tlb"

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

New Post(0)