Results 1 to 5 of 5

Thread: For you VBScript FREAKS out there!

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Wink 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

  2. #2
    Lively Member RobIII's Avatar
    Join Date
    Jul 2002
    Location
    Netherlands
    Posts
    112
    I don't like the ScriptLet typelib that much...Just an opinion....

    here's an api-way :

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type GUID
    4.     Data1 As Long
    5.     Data2 As Integer
    6.     Data3 As Integer
    7.     Data4(0 To 7) As Byte
    8. End Type
    9.  
    10. Private Declare Function CoCreateGuid Lib "ole32" (pguid As GUID) As Long
    11. Private Declare Function UuidToString Lib "rpcrt4" Alias "UuidToStringA" (pguid As GUID, pszGuid As Long) As Long
    12. Private Declare Function RpcStringFree Lib "rpcrt4" Alias "RpcStringFreeA" (psz As Long) As Long
    13. Private Declare Function CopyLongToString Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, lpString2 As Any) As Long
    14.  
    15. Public Function CreateGuid() As String
    16.     Dim TheGuid As GUID
    17.     Dim pszGuid As Long
    18.    
    19.     CoCreateGuid TheGuid
    20.     UuidToString TheGuid, pszGuid
    21.    
    22.     CreateGuid = Space(256)
    23.     CopyLongToString CreateGuid, ByVal pszGuid
    24.    
    25.     RpcStringFree pszGuid
    26.     CreateGuid = UCase(Mid(CreateGuid, 1, InStr(1, CreateGuid, vbNullChar) - 1))
    27. End Function
    28.  
    29. Private Sub Form_Load()
    30.     Debug.Print CreateGuid
    31. End Sub
    Rob.

    Window XP: From the makers of DoubleSpace...

    Press ANY key... NO, NO, NO!!! NOT THAT ONE!!!!

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    Thanks but did you notice I said VBScript?

  4. #4
    Lively Member RobIII's Avatar
    Join Date
    Jul 2002
    Location
    Netherlands
    Posts
    112
    Woops... My Mistake...

    Sorry
    Rob.

    Window XP: From the makers of DoubleSpace...

    Press ANY key... NO, NO, NO!!! NOT THAT ONE!!!!

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    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
  •  



Click Here to Expand Forum to Full Width