Core Function DLLStructCreateUnion

From Sputnik Wiki
Jump to: navigation, search
DLLStructCreateUnion( <def string> )

Contents

Description

Creates a C/C++ style structure (Union) to be used with DLLCall

This is just a simple wrapper for DLLStructCreate that automatically inserts the union property into your struct by placing "union " before the def string like so DllStructCreate("union int a;float b");

Parameters

def string

See DLLStructCreate( ) for def string.

Return Value

See DLLStructCreate( ) for return value.

Remarks

See DLLStructCreate( ) for remarks.

Example

See DLLStructCreate( ) for more examples.

# A union will place all the objects at the same address
$a = DLLStructCreateUnion("int a;float b");
 
# so when we set the floats value it also set the ints value
DLLStructSetData($a,"b", 133.77);
 
# Its size is 4 since they are both at the same offset
say "Size: " . DLLStructGetSize( $a );
 
# Lets read the int value as a hex and it will give us the floats
# value as a hex (since we wrote to the float which also set the int)
$value = DllStructGetData($a,"a");
printf( "Value is %#x\n", $value );
 
# Prints
# Size: 4
# Value is 0x4305c51f
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox