Jump to content

DLLStructDelete


Recommended Posts

I recently found that script to be able to get a MAC address of a specified computer

Local $MAC,$MACSize
Local $i,$s,$r,$iIP
    
;Create the struct
;{
;    char    data[6];
;}MAC
    $MAC        = DllStructCreate("byte[6]")

;Create a pointer to an int
;    int *MACSize;
    $MACSize    = DllStructCreate("int")

;*MACSize = 6;
    DllStructSetData($MACSize, 1, 6)

;call inet_addr($sIP)
    $r = DllCall ("Ws2_32.dll", "int", "inet_addr", "str", $sIP)
    $iIP = $r[0]

;Make the DllCall
    $r = DllCall ("iphlpapi.dll", "int", "SendARP", "int", $iIP, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))

;Format the MAC address into user readble format: 00:00:00:00:00:00
    $s    = ""
    For $i = 0 To 5
        $s = $s & Hex(DllStructGetData($MAC, 1, $i+1), 2)
    Next

;Must free the memory after it is used
    ;DllStructDelete($MAC)
    ;DllStructDelete($MACSize)

;Return the user readble MAC address
    Return $s

The DLLStructDelete doesn't seem to exist anymore. Is there anything else that replace that ??

Thank you. Cheers!!!

Link to comment
Share on other sites

From the help file.

To release allocated memory just reset the returned variable to 0.

Link to comment
Share on other sites

  • 2 months later...

If a function makes a dll call and returns the result with

Return DllStructGetData($thedata,1)

will the DllStruct memory be deallocated on exit? or should it return like this:

$return = DllStructGetData($thedata,1)
$thedata=0
Return $return

?

Link to comment
Share on other sites

If a function makes a dll call and returns the result with

Return DllStructGetData($thedata,1)

will the DllStruct memory be deallocated on exit? or should it return like this:

$return = DllStructGetData($thedata,1)
$thedata=0
Return $return

?

If $thedata is Local, it will be freed upon exiting the function, like all other local variables.

"be smart, drink your wine"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...