Click to See Complete Forum and Search --> : Assigning a memory address to a variable


Marco
August 24th, 1999, 03:27 AM
private Type SECURITY_DESCRIPTOR
Descriptor(SECURITY_DESCRIPTOR_MIN_LENGTH) as Byte
End Type

private Type SECURITY_ATTRIBUTES
nLength as Long
lpSecurityDescriptor as Long
bInheritHandle as Long
End Type

private Declare Function InitializeSecurityDescriptor Lib "advapi32.dll" (pSecurityDescriptor as SECURITY_DESCRIPTOR, byval dwRevision as Long) as Long

private Declare Function SetSecurityDescriptorDacl Lib "advapi32.dll" (pSecurityDescriptor as SECURITY_DESCRIPTOR, byval bDaclPresent as Long, byval pDacl as Long, byval bDaclDefaulted as Long) as Long

private Declare Function CreateNamedPipe Lib "kernel32" Alias "CreateNamedPipeA" (byval lpName as string, byval dwOpenMode as Long, byval dwPipeMode as Long, byval nMaxInstances as Long, byval nOutBufferSize as Long, byval nInBufferSize as Long, byval nDefaultTimeOut as Long, lpSecurityAttributes as SECURITY_ATTRIBUTES) as Long

Dim pSD as SECURITY_DESCRIPTOR
Dim sa as SECURITY_ATTRIBUTES


............


' create a security descriptor that allows anyone to write to
' the pipe...
'
result = InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)

' add a null disc. ACL to the security descriptor.
'
result = SetSecurityDescriptorDacl(pSD, 1, 0&, 0)

sa.nLength = len(sa)
sa.lpSecurityDescriptor = pSD <--------
sa.bInheritHandle = 1

.............





I wanna assign the memory address of variable pSD to sa.lpSecurityDescriptor; how could i do it ?
Thank you in advance for your help.....

Lothar Haensler
August 24th, 1999, 04:25 AM
try the CopyMemory API, expect crashes and save your work frequently... ;-)
call CopyMemory( sa.lpSecurityDescriptor , pSD )

Wayne Fuller
August 24th, 1999, 07:53 AM
Use C++.

Chris Eastwood
August 24th, 1999, 08:19 AM
... Or use the CopyMemory api, or the StrPtr, VarPtr or ObjPtr (undocumented) keywords in VB5/6.




Chris Eastwood

CodeGuru - the website for developers
http://www.codeguru.com/vb

Marco
August 24th, 1999, 09:23 AM
Thanks for your answer; the function VarPtr works properly......Bye