Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link Windows API: Creating a GUID 2003-04-29 -- Jim Kane Newsgroups: comp.lang.clarion
Notice in the c prototype ** ? That means pointer to a pointer. You need to
do one more copy.
What you are getting back is a pointer to the string. My code uses call by
address since the dlls involved are not found on all os but you can use a
lib if all your customers will have nt or higher
if SELF.CallDllCl.Init(Dllname,SELF.Debug)
SELF.TakeError('RpcRt4.dll not found','CreateGuid')
do procret
end
SELF.calldllcl.setprocfailcode(1)
procresult = SELF.calldllcl.call('UuidCreate',plpGuid)
if procresult<>0
If procresult = 1824 then
SELF.TakeError('No NIC in this Machine','CreateGuid')
elsif res = 1739
SELF.TakeError('Unable to get NIC Address','CreateGuid')
else
SELF.TakeError('UUIDCreate Failed','CreateGuid')
end
do procret
End
if ~omitted(3) then
!Convert to a string
ProcResult=SELF.calldllcl.call('UuidToStringA', plpguid
,address(UuidStrPtr))
If ProcResult<>0 or ~uuidstrptr then
SELF.TakeError('Uuidstr fail','CreateGuid')
do procret
End
!Copy string from RPC Owned Memory to CW memory
if size(pGuidStr)< lstrlen(uuidstrptr)+1 then
SELF.TakeError('Guid string is too short:
Required='&lstrlen(uuidstrptr) & ' provided='&size(pGuidStr),'CreateGuid')
do procret
else
lstrcpy(address(tempcStr),UuidStrPtr)
pGuidStr=tempcstr
res=return:benign
end
end
do procret
procret routine
!free the RPC Memory, if any was obtained
if uuidstrptr then
SELF.calldllcl.call('RpcStringFreeA', address(UuidStrPtr))
end
SELF.CallDllCl.kill()
return res
Notice the extra lstrcpy and finally the call to rpcstringfreeA
Jim Kane
"Charles Ballard"
Today is November 23, 2024, 3:36 am This article has been viewed 35404 times. Google search has resulted in 367 hits on this article since January 25, 2004.
|
|