CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Location
    Piacenza, ITALIA
    Posts
    30

    Assigning a memory address to a variable



    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.....


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Assigning a memory address to a variable

    try the CopyMemory API, expect crashes and save your work frequently... ;-)
    call CopyMemory( sa.lpSecurityDescriptor , pSD )


  3. #3
    Join Date
    May 1999
    Location
    Texas, USA
    Posts
    568

    Re: Assigning a memory address to a variable

    Use C++.


  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Assigning a memory address to a variable

    ... 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

  5. #5
    Join Date
    May 1999
    Location
    Piacenza, ITALIA
    Posts
    30

    Re: Assigning a memory address to a variable

    Thanks for your answer; the function VarPtr works properly......Bye


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured