Jump to content
Sign in to follow this  
AllSystemGo

DLLStructDelete

Recommended Posts

AllSystemGo

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

Share this post


Link to post
Share on other sites
eltorro

From the help file.

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

Share this post


Link to post
Share on other sites
AllSystemGo

Thank you Zedna and I'm sorry for that eltorro I didn't see it. I'll look more closely next time.

Share this post


Link to post
Share on other sites
drlava

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

?

Share this post


Link to post
Share on other sites
Siao

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"

Share this post


Link to post
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
Sign in to follow this  

×