|
-
Sep 20th, 2002, 12:37 PM
#1
Thread Starter
PowerPoster
For you VBScript FREAKS out there!
Someone shared this with me yersterday. Cool for generating GUIDS in VBScript.
Code:
function GetNewGUID()
set TypeLib = server.CreateObject("Scriptlet.TypeLib")
GetNewGUID = TypeLib.Guid
Set TypeLib = nothing
end function
-
Sep 20th, 2002, 12:47 PM
#2
Lively Member
I don't like the ScriptLet typelib that much...Just an opinion....
here's an api-way :
VB Code:
Option Explicit
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Private Declare Function CoCreateGuid Lib "ole32" (pguid As GUID) As Long
Private Declare Function UuidToString Lib "rpcrt4" Alias "UuidToStringA" (pguid As GUID, pszGuid As Long) As Long
Private Declare Function RpcStringFree Lib "rpcrt4" Alias "RpcStringFreeA" (psz As Long) As Long
Private Declare Function CopyLongToString Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, lpString2 As Any) As Long
Public Function CreateGuid() As String
Dim TheGuid As GUID
Dim pszGuid As Long
CoCreateGuid TheGuid
UuidToString TheGuid, pszGuid
CreateGuid = Space(256)
CopyLongToString CreateGuid, ByVal pszGuid
RpcStringFree pszGuid
CreateGuid = UCase(Mid(CreateGuid, 1, InStr(1, CreateGuid, vbNullChar) - 1))
End Function
Private Sub Form_Load()
Debug.Print CreateGuid
End Sub
Rob.
Window XP: From the makers of DoubleSpace...
Press ANY key... NO, NO, NO!!! NOT THAT ONE!!!!
-
Sep 20th, 2002, 12:48 PM
#3
Thread Starter
PowerPoster
Thanks but did you notice I said VBScript?
-
Sep 20th, 2002, 12:49 PM
#4
Lively Member
Woops... My Mistake...
Sorry
Rob.
Window XP: From the makers of DoubleSpace...
Press ANY key... NO, NO, NO!!! NOT THAT ONE!!!!
-
Sep 20th, 2002, 12:49 PM
#5
Thread Starter
PowerPoster
no prob
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|