не дает использовать эту функцию
говорит что не может найти entry point для cocreateguid в ole32.dll
вычитала что нужно зарегистрировать com-библиотеку перед использованием cocreateguid
а как?
Public Declare Function CoCreateGuid Lib "ole32.dll" (ptrGuid As Guid) As Long
Public Declare Function CoCreateGuid Lib "ole32.dll" (ptrGuid As Guid) As Long
Public Type Guid
PartOne As Long
PartTwo As Integer
PartThree As Integer
PartFour(7) As Byte
End Type
'
Public Function Guid() As String
Dim lRetVal As Long
Dim udtGuid As Guid
Dim sPartOne As String
Dim sPartTwo As String
Dim sPartThree As String
Dim sPartFour As String
Dim iDataLen As Integer
Dim iStrLen As Integer
Dim iCtr As Integer
Dim sAns As String
On Error GoTo ErrorHandler
sAns = ""
lRetVal = CoCreateGuid(udtGuid)
If lRetVal = 0 Then
'First 8 chars
sPartOne = Hex$(udtGuid.PartOne)
iStrLen = Len(sPartOne)
iDataLen = Len(udtGuid.PartOne)
sPartOne = String((iDataLen * 2) - iStrLen, "0") _
& Trim$(sPartOne)
'Next 4 Chars
sPartTwo = Hex$(udtGuid.PartTwo)
iStrLen = Len(sPartTwo)
iDataLen = Len(udtGuid.PartTwo)
sPartTwo = String((iDataLen * 2) - iStrLen, "0") _
& Trim$(sPartTwo)
'Next 4 Chars
sPartThree = Hex$(udtGuid.PartThree)
iStrLen = Len(sPartThree)
iDataLen = Len(udtGuid.PartThree)
sPartThree = String((iDataLen * 2) - iStrLen, "0") _
& Trim$(sPartThree) 'Next 2 bytes (4 hex digits)
'Final 16 chars
For iCtr = 0 To 7
sPartFour = sPartFour & _
Format$(Hex$(udtGuid.PartFour(iCtr)), "00")
Next
'To create GUID with "-", change line below to:
'sAns = sPartOne & "-" & sPartTwo & "-" & sPartThree _
'& "-" & sPartFour
sAns = sPartOne & sPartTwo & sPartThree & sPartFour
End If
Guid = sAns
Exit Function
ErrorHandler:
'return a blank string if there's an error
Exit Function
End Function
Private Declare Function CoCreateGuid Lib "ole32.dll" (buffer As Guid) As Long
Private Declare Function StringFromGUID2 Lib "ole32.dll" (buffer As Guid, ByVal lpsz As Long, ByVal cbMax As Long) As Long
Private Type Guid
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Private Function getGUID() As String
Dim buffer As Guid
Dim s As String
CoCreateGuid buffer
s = String$(128, 0)
getGUID = Left$(s, StringFromGUID2(buffer, StrPtr(s), Len(s)) - 1)
End Function
Сейчас этот форум просматривают: Yandex-бот и гости: 178