Results 1 to 6 of 6

GUID code for 32bit to work with 64bit also

Threaded View

  1. #1
    Registered User
    Join Date
    07-13-2010
    Location
    Barossa SA, Australia
    MS-Off Ver
    Excel 2007
    Posts
    48

    Smile GUID code for 32bit to work with 64bit also

    Hi All,

    I have some code that has been working very well at our work place. The problem is some of the PC's have been upgraded to 64bit and on these PC's the code gets the following Complie error message

    "The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PtrSafe attribute."

    The code is below and I need it to be able to work on both 32bit and 64bit machine's is this possiable?

    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.dll" (ByRef pGuid As GUID) As Long
    
    Public Function GetGUID() As String
    
      Dim I As Integer
      Dim myGUID As GUID
      Dim S As String
      
        If (CoCreateGuid(myGUID) = 0) Then
           S = _
             String(8 - Len(Hex$(myGUID.Data1)), "0") & Hex$(myGUID.Data1) & "-" & _
             String(4 - Len(Hex$(myGUID.Data2)), "0") & Hex$(myGUID.Data2) & "-" & _
             String(4 - Len(Hex$(myGUID.Data3)), "0") & Hex$(myGUID.Data3) & "-"
               For I = 0 To 7
                 S = S & IIf(myGUID.Data4(I) < &H10, "0", "") & Hex(myGUID.Data4(I))
                 If I = 1 Then S = S & "-"
               Next I
           GetGUID = S
        End If
    
    End Function
    Thanks in advance.BJ
    Last edited by BJ5352; 05-26-2013 at 10:58 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1