A function without structure type parameters The GetSystemDirectory function is exported by "kernel32.dll" and is used to retrieve the path of the system directory. The declaration of this function in SWFKit Pro should be
dllimport "kernel32.dll" stdcall unsigned int
GetSystemDirectoryA(char *lpBuffer, unsigned int uSize) as getSysDir;
where "kernel32.dll" indicates the library name (name of the dll file that exports the function).
Since "kernel32.dll" is a system file that SWFKit Pro can find it, at here we need not use a full
path name like "c:
var myDll = getAdditionalFile("mydll.dll");
dllimport myDll stdcall void MyFunc();
"stdcall" indicates the calling convention. SWFKit Pro 3 now supports two kinds of calling convention:
stdcall and cdecl. Typically, Windows API functions use stdcall calling convention, whereas c/c++ functions
use cdecl calling convention. After "stdcall" is the return value, function name, and the parameter list in
a pair of brackets You can also omit the parameter names of the functions, e.g.
dllimport "kernel32.dll" stdcall unsigned int
GetSystemDirectoryA(char *, unsigned int) as getSysDir;
The data types that can be used in function declaration is listed in 2.58.
And "void" can only be used for the return type, which means no return. A parameter
cannot be of "void" type. After the "as" keyword is the alias of the function. If
you specify an alias for a function, you must use its alias to call it in FFish Script;
otherwise the name of the function will be used.
A function with structure type parameters or returns a structure In this case, you would have to declare the structure type first. E.g. the FindFirstFile function:
struct
{
unsigned int dwLowDateTime;
unsigned int dwHighDateTime;
} FILETIME;
struct
{
unsigned int dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
unsigned int nFileSizeHigh;
unsigned int nFileSizeLow;
unsigned int dwReserved0;
unsigned int dwReserved1;
char cFileName[260];
char cAlternateFileName[14];
} WIN32_FIND_DATA;
dllimport "kernel32.dll" stdcall pointer
FindFirstFileA(char *, WIN32_FIND_DATA*) as findFirstFile;