Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28706 Discussions

Is there a function available to create GUID ?

fbalderasintel
664 Views
Is there a library that I can link, that has a function to create a GUID ? Using Fortran 11.1.048 on VS 2008.n 11.1.048 on VS 2008.
0 Kudos
1 Solution
Steven_L_Intel1
Employee
664 Views
CoCreateGuid - it ought to be in module OLE32 but isn't. So declare it yourself. For example:

[fortran]use ifwinty

interface
function CoCreateGuid (pguid)
import
!DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"CoCreateGuid" :: CoCreateGuid
integer(LONG) :: CoCreateGuid
type(T_GUID), intent(OUT) :: pguid
end function CoCreateGuid
end interface
!DEC$ OBJCOMMENT LIB:"ole32.lib"

type(T_GUID) :: my_guid
integer(LONG) :: res

res = CoCreateGuid (my_guid)

if (res ==S_OK) then
  print 101, my_guid%data1,my_guid%data2,my_guid%data3,my_guid%data4(1:2), &
    my_guid%data4(3:8)
101 format (Z8.8,'-',Z4.4,'-',Z4.4,'-',Z4.4,'-',Z12.12)
else
  print *, "Error ", res
end if
end[/fortran]

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
665 Views
CoCreateGuid - it ought to be in module OLE32 but isn't. So declare it yourself. For example:

[fortran]use ifwinty

interface
function CoCreateGuid (pguid)
import
!DEC$ ATTRIBUTES STDCALL, REFERENCE, DECORATE, ALIAS:"CoCreateGuid" :: CoCreateGuid
integer(LONG) :: CoCreateGuid
type(T_GUID), intent(OUT) :: pguid
end function CoCreateGuid
end interface
!DEC$ OBJCOMMENT LIB:"ole32.lib"

type(T_GUID) :: my_guid
integer(LONG) :: res

res = CoCreateGuid (my_guid)

if (res ==S_OK) then
  print 101, my_guid%data1,my_guid%data2,my_guid%data3,my_guid%data4(1:2), &
    my_guid%data4(3:8)
101 format (Z8.8,'-',Z4.4,'-',Z4.4,'-',Z4.4,'-',Z12.12)
else
  print *, "Error ", res
end if
end[/fortran]
0 Kudos
fbalderasintel
664 Views
I works great ! and on x64 as well. Thanks
0 Kudos
Reply