The import command
The import command allows you to export functions from DLL. The keyword import is followed by DLL filename, which contains imported functions, and afterwards we open the description block. Each line of the block contains a description of the imported function, i.e. a type of the return value, if any, and a function name are aligned with parameters separated by commas and enclosed in parentheses. You can substitute a new function name for the name of the imported file. To rename the function, you need to use -> after the description and a new name. When function is imported, calling DLL function is made in the same way as calling function written in Gentee.
import "kernel32.dll"
{
uint CloseHandle( uint )
uint CopyFileA( uint, uint, uint ) -> CopyFile
uint CreateFileA( uint, uint, uint, uint, uint, uint, uint ) -> CreateFile
uint CreateProcessA( uint, uint, uint, uint, uint, uint, uint, uint,
STARTUPINFO, PROCESS_INFORMATION ) -> CreateProcess
}
If you are going to run the Gentee program from your own EXE file, you can use functions from the EXE module. To do it, specify the name of the DLL file as an empty string and read about passing the addresses of the functions to be imported in the Configuring and running Gentee section.
Attributes
cdeclare
Means that the __cdecl functions are imported. By default, the imported functions are considered to be the __stdcall functions.
import "myfile.dll" <cdeclare>
{
...
}
link
In this case, a required .dll file will be included in a .ge file; while launching a program the .dll file is written to the temporal directory where the program load it. The .dll file will be deleted after the program has ended. In other words, if you don't want some extra .dll files to be distributed, but you doubt if the files have been stored before in a user's computer, this attribute will be helpful for you. It is desirable that the complete path to the .dll file should be specified.
import $"c:\mypath\myfile.dll" <link>
{
...
}
exe
This attribute should be used if you get to know the relative path from your program to the .dll file. This is an example illustrated my.dll loading from the subdirectory Plugins.
import $"plugins\my.dll" <exe>
{
...
}