<form id="hbx9t"></form>

<noframes id="hbx9t">

    <em id="hbx9t"><span id="hbx9t"></span></em>

        <noframes id="hbx9t"><address id="hbx9t"><th id="hbx9t"><progress id="hbx9t"></progress></th></address>
        office交流網--QQ交流群號

        Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

        Word交流群:218156588             PPT交流群:324131555

        獲取全球唯一識別碼GUID

        2020-05-30 08:00:00
        tmtony8
        原創
        13801

              全局唯一標識符(GUID,Globally Unique Identifier)是一種由算法生成的二進制長度為128位的數字標識符。GUID主要用于在擁有多個節點、多臺計算機的網絡或系統中。GUID 的格式為“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中的 x 是 0-9 或 a-f 范圍內的一個32位十六進制數。在理想情況下,任何計算機和計算機集群都不會生成兩個相同的GUID。



        他的作用是標識特定的組件、程序、文件、數據、用戶等,并可以在網絡中使用


        下面是獲取GUID的自定義函數,
        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
        
        
        Public Function GetNewGuild() As String
            Dim g As GUID
            Dim b() As Byte
            Dim lSize As Long
            Dim lR As Long
            CoCreateGuid g
            lSize = 40
            ReDim b(0 To (lSize * 2) - 1) As Byte
            lR = StringFromGUID2(g, VarPtr(b(0)), lSize)
            GetNewGuild = Left$(b, lR - 1)
        End Function
        

          分享