@LIB

Top  Previous  Next

Syntax:

 

@LIB( <dllname>, <function name>, <ret_val type>, args… )

 

Description:

 

This function allows expert developers to make calls to Windows API functions and functions in other DLLs directly from a DialogScript program. Using this function requires understanding of the Windows API and languages such as C or Pascal, and you will need the Windows API documentation.

The <dllname> argument specifies the DLL containing the function that is to be called. This DLL should previously have been successfully loaded using the LOADLIB command.

The <function name> argument specifies the name of the function exported by the DLL that you wish to call.

The <ret_val type> argument specifies the type of value returned by the DLL function. This should be NIL: if the function returns C type VOID, INT: if it is a binary type such as DWORD, BOOL: if it is a boolean (BOOL) type having a value TRUE or FALSE, or STR: if it is a pointer to a null-terminated string (LPSTR). This parameter is important as it determines how the return value is converted into the string expected by VDS.

The remaining arguments specify the arguments to the DLL function, of which there may be a maximum of 8. Warning: If all the arguments are not specified in exactly the right format, your script will probably hang or crash! The type must be specified since the values must be converted to the correct type when the function is called. VDS attempts to choose the correct type based on the value of each argument: whether it is a valid number, a string, or one of the words TRUE or FALSE. To avoid errors, however, it is better to prefix each value with one of the type specifiers BOOL:, INT: or STR: described above.

Many API and DLL functions require var arguments which are pointers to locations in memory that may contain a value on entry or which may contain data when the function has finished. You can use the @BINARY function to create such values in VDS variables, and then pass the address of these variables to the DLL function. You can use the @VAL function to convert binary values back to VDS strings upon the function's return. To create a STRUCT data structure, set a VDS variable to a string of the correct number of bytes, then pass its address to the DLL function using @ADDR.

OK:

Unchanged.

Example:

# create INTERNET_VERSION_INFO struct to hold major ver / minor ver

%V = @BINARY(dword,0)@BINARY(dword,0)

# create dword containing size of buffer

%U = @BINARY(dword,@LEN(%V))@BINARY(dword,0)

IF @lib(WININET,InternetQueryOptionA,bool:,0,40,@addr("%V"),@addr("%U"))

  %V = @BINARY(dword,0)@BINARY(dword,0)

  %%ftp_ver = @VAL(@BINARY(%V,1,4)).@VAL(@SUBSTR(%V,5,8))

END

 

See a more advanced example...

See also: