Announcement

Collapse
No announcement yet.

VB Copymem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tom Hanlin
    replied
    Scott, once you've succeeded in stuffing the top part of the buffer into a
    variable of type EVENTLOGRECORD, you'll be able to access the individual
    members of that variable without further processing. It's all taken care of
    you by that CopyMem, POKE$, MoveMemory, LSET, or whatever equivalent is
    being done after the buffer is read.

    Ron, my point was that the second VARPTR in that call simply doesn't function,
    since the value is being passed BYREF, not BYVAL. There's no use in adding
    all that complication just to pass the parameter incorrectly!

    Using BYVAL VARPTR(whatever) does have the advantage of allowing you to override
    BYREF parameter types like EVENTLOGRECORD if you'd prefer to use something else--
    so it's not necessary to modify the declarations for this purpose.


    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Guest
    Guest replied
    Tom, Len(EVENTLOGRECORD) does work fine.

    The two byval(varptr)) for bytes read and bytes needed respectively are equivalents of passing the long int from basic.
    There are too many languages with different calling styles. The PB definition with the EVENTRECORD in the function prototype should be changed to allow any buffer pointer to be passed I believe. Scott, you can copy the 56 bytes (or whatever the defined length of the record is into the EVENTRECORD structure. The remaining pseudo members of the structure will need variables allocated to hold that data. Be cognizant of padding.

    Leave a comment:


  • Scott Turchin
    replied
    OK I think I have a working copy, had to modify even the working copy here.

    Question is, in the end, will I be able to say:

    Msgbox format$(lpBuffer.EventID)

    Or is it that I have to take each byte and do a Chr$() to it and then append it to a string and parse it?
    That is ugly, but if so, so be it...
    It'd be nice to have a use for that TYPE, would make life easier


    Scott

    ------------------
    Scott

    Leave a comment:


  • Tom Hanlin
    replied
    It would really be easier to use a string for the buffer, which would allow
    you to POKE$ or LSET the results into the structure.

    Mmm, Len(EVENTLOGRECORD) is probably not doing what you want. LEN is
    for variables: think Len(lpBuffer) here.

    pnMinNumberOfBytesNeeded does not need to be initialized. It's a
    returned value.

    This bit is not right:
    Code:
    ByVal VarPtr(pnBytesRead), _
    VarPtr(pnMinNumberOfBytesNeeded) )
    Skip the ByVal and VarPtr parts, you just need to pass the variables here.


    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Jules Marchildon
    replied
    Code:
    '----------------------------------------------------------------------------
    ' Tip from Lance Edmonds FEB/09/2001.
    ' A PowerBasic Replacement for the API CopyMemory() function
    '----------------------------------------------------------------------------
    SUB CopyMemoryPB(ByVal lpDest AS DWORD,ByVal lpSource AS DWORD,ByVal cbLength AS LONG)
        POKE$ lpDest, PEEK$(lpSource, cbLength)
    END SUB

    Leave a comment:


  • Jim Huguley
    replied
    MoveMemory VARPTR(rBuff), VARPTR(eBuff(eBytePointer)), StrucLen

    P.S. Don't forget to give StrucLen a length

    ------------------
    Jim..
    [email protected]


    [This message has been edited by Jim Huguley (edited June 20, 2001).]

    Leave a comment:


  • Scott Turchin
    started a topic VB Copymem

    VB Copymem

    What is an appropriate substitution for CopyMem?
    This is gettign awefully complicated just to read an event log, but will be worth it for everyone when I'm done..

    (Still on the event log problem)

    Code:
    Dim rBuff As EVENTLOGRECORD
    Local eBuff() As Byte
    Local StrucLen      As Long
    
    Do While rBuff.RecordNumber < EvtRecNo
        ret = ReadEventLog(EventLogHwd, _
                           EvtReadFlags, _
                           rBuff.RecordNumber + 1, _
                           eBuff(0), 16384, rBytesRead, _
                           rBytesNeeded)
        If ret = 0 Then Exit Function
    
        eBytePointer = 0
        Do While eBytePointer < rBytesRead 
            CopyMem rBuff, eBuff(eBytePointer), StrucLen
    ------------------
    Scott
Working...
X