|
CallDll$ | |
Result$ = CallDll$(DLLNumber, FunctionName$, [Param List]) | |
Parameters: DLLNumber = The DLL number FunctionName$ = The name of the function you want to call [Param List] = Specifies between 0 and 64 parameters that are passed to the function |
|
Returns: Result$ = Holds the return value of the DLL function |
|
With CallDll$ you can call a function within a DLL that returns a null terminated string pointer. PlayBASIC expects the string to be null terminated, which means the string should use the zero byte/character for the end marker. Parameter Passing Method: When PlayBASIC calls external DLL functions, the basic numeric data types like integer and floating point values are passed in as 32bit format respectively. Strings and Typed variables require some intervention prior to be being passed to the DLL, this is because internally strings and types are held in a unique format inside PlayBASIC, a form that doesn't exist outside of PlayBASIC. Strings When we pass a PlayBASIC string to a function, the CallDll$ will compute a pointer to the first character in the string and then pass that through. The data in the string will be null terminated, which just means that it has a zero at the end of character data, you might know this format as a C string, which is fairly common format for strings. It's important to understand that when a string is passed, the string data isn't a copy of the internal PlayBASIC string. This means that if the function you call, modifies the string then the string data inside PB will be modified also. Now depending upon the function, this may or may not be desirable, in particular if the DLL atempts to delete or write to the string outside of it's allocated memory, then PlayBASIC won't appreciate that. In other words, it'll probably crash. If you have problems you suspect occur from this, then you can allocate some memory yourself and store the string data in that and pass a pointer in it's place. FACTS * Please read the calldll page for more general information about CallDLL operations Mini Tutorial: In this mock up sample we're calling a function "MyUpperCase" from a pretend DLL called "MyStringFunctions.dll". The function expects a string input and string returns a string also. If we assume the function copies the string and converts the characters into upper case, our call might look like this.
|
Related Info: | CallDll | CallDll# | CallFunction | DllCallConv | FunctionIndex | GetFreeDLL | LoadDLL : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |