Sei sulla pagina 1di 2

U500 TECHNOTE: Software version v5.

02
Subject: Using the CALLDLL function from a MMI program to call any DLL. This comman can be
use to call any e!isting DLL" or can be use to call a function to perform a tas# that can not be
accomplishe from $ithin a U%&& program.
Synta!: '( ) CALLDLL *llname+" *function+" *string+
$here '( ) U%&& user 'ariable ,'& - '.%%/" function return 'alue.
llname ) name of user DLL to be calle.
function ) function in the user DLL to be calle.
string ) optional string to pass to DLL function.
Usage: This comman is use to call any user DLL. The prototype of the function that can be calle
from a U%&& program is:
ouble 0unc1ame , ouble 2'arlist" char 2str /
The function $ill return a ouble into the user 'ariable specifie in the CALLDLL comman. The
argument pointer to a ouble is the location of U%&& user 'ariable 3&. The U%&& user 'ariables are store
se4uentially as oubles. The number of user 'alues is efine in D56CD5.7" 1UMUS583A8" this
constant is currently set to .%9" for '& - '.%%. Thus" any user 'ariable $ill be a'ailable to the calle DLL
function. The string passe to the DLL is optional an can be use if the function being calle re4uires a
string. Unless this prototype is the same for the DLL function to be calle" a $rapper function an DLL
$ill nee to be create to call the esire function.
This is an e!ample sho$ing ho$ to call the U%&& DLL" :I1%&&;..DLL" using the CALLDLL
comman. The follo$ing is the c coe of the DLL for three ifferent functions" the DLL create is name
U%&&US58.DLL:
(inclue <math.h=
(inclue >c:?u%&&?ntlib?4lib?aerotype.h>
(inclue >c:?u%&&?ntlib?4lib?buil.h>
(inclue >c:?u%&&?ntlib?$api?$api.h>
ouble @@eclspec,lle!port/ @stcall 8eaAosB%, ouble 2pUser3ar" char 2str /
C
D2 This function stores the real-time position of the E a!is in 3B%. 2D
2,pUser3arFB%/ ) :AAIAer8eaAosition,G/H
return,&/H
I
ouble @@eclspec,lle!port/ @stcall SenCm, ouble 2pUser3ar" char 2str /
C
D2 This function sens a comman to the U%&&. 2D
return, :AAIAerSen,str/ /H
I
ouble @@eclspec,lle!port/ @stcall Sol'eJuaratic, ouble 2pUser3ar" char 2str /
C
D2 This function calculates the roots of the 4uaratic e4uation. The a" b" an c
terms are in 3K&" 3KK" an 3K." respecti'ely. The roots $ill be calculate an
returne in 3& an 3K. 2D
ouble a)2,pUser3arFK&/H
ouble b)2,pUser3arFKK/H
ouble c)2,pUser3arFK./H
if , b2b-L2a2c<& / DDimaginary result
return,-K/H
2pUser3ar ) ,-bFs4rt,b2b-L2a2c//D,.2a/H
2,pUser3arFK/ ) ,-b-s4rt,b2b-L2a2c//D,.2a/H
return,&/H
I
To buil a DLL that can be calle e!ternally re4uires a D50 file that lists the functions use. The
follo$ing is the associate D50 file:
LIM8A8N u%&&user
5EA68TS
8eaAosB%
SenCm
Sol'eJuaratic
The follo$ing is the U%&& program" $hich calls the ifferent functions in the U%&&US58.DLL:
'%)callll >u%&&user.ll>">8eaAosB%>
me i >E a!is position ) O'B%>
'K)callll >u%&&user.ll>">SenCm>">i !>
me i *:AAIAerSen return coe ) O'K+
'K&)K
'KK)L
'K.);
'%)callll >u%&&user.ll>">Sol'eJuaratic>
me i >ret)O'%"Froot)O'&"-root)O'K>
The function 8eaAosB% calls the :AAIAer8eaAosition function $ithin the :I1%&&;..DLL. The
return 'alue of the function" the real-time position of the E a!is" is returne into user 'ariable 3B%. The
SenCm function passes the string" *i !+" to the :AAIAerSen function of :I1%&&;..DLL. The
return 'alue of the :AAIAerSen function $ill be passe bac# to the U%&& program into user 'ariable
3K. The other function" Sol'eJuaratic" is a basic function performing the operation of fining the roots
of a 4uaratic e4uation. The coefficients" a" b" an c" of the 4uaratic e4uation are store in 'K&" 'KK" an
'K." respecti'ely. If imaginary roots $ill result" the function $ill return a -K into '%" other$ise" the
e4uation is sol'e an the roots $ill be store in '& an 'K.
Aitional commans ae in '%.&L:
The follo$ing commans ha'e been ae to #eep a DLL loae in memory uring e!ecution of
a program an to free a DLL from memory.
Synta!:
'( ) L6ADDLL *llname+
$here"
*llname+ is the name of the ll to loa into memory
'( ,'& P '.%%/ returns the hanle to the ll
'( ) 0855DLL '(
$here"
'( ,argument/ is the hanle of the ll that is open
'( ,return/ returns &.

Potrebbero piacerti anche