- Using a Visual Basic DLL
- Step 1: Registering the DLL
- Step 2: Declaring the DLL
- Step 3: Handling the DLL
- Step 4: Freeing the DLL
Calling a DLL written in Visual Basic
Visual Basic (like many other languages) allows you to create custom DLLs. WINDEV gives you the ability to use these DLLs from your applications.
In most cases, a DLL written in Visual Basic is a class contained in a Visual Basic module and compiled as an ActiveX DLL. This class contains:
- features (methods, functions, ...).
- members. In most cases, these members can be accessed via the serialization properties. Two types of properties are available:
- "Get" properties, used to retrieve the value of a member.
- "Set" or "Let" properties, used to assign a member (the type of the property that will be used depends on the type of the member).
: In a WINDEV application, these specific DLLs cannot
be called by API
. Indeed, these DLLs do not comply with the WINAPI standard of Windows. These DLLs are used in the WINDEV projects as automation objects. For more details, see Automation objects
Using a Visual Basic DLL
To use a DLL written in Visual Basic in a WINDEV project:
- Register the DLL if necessary.
- Declare the DLL in a WLanguage process.
- Handle the DLL as an OLE object.
- Free the DLL.
Step 1: Registering the DLL
If the DLL written in Visual Basic was developed:
- on the computer where the WINDEV project is run: there is no need to register the DLL toward Windows.
- on a computer other than the one where the WINDEV project is run: you must register the DLL with MS Windows by running the following command line: "regsvr32 <DLLName>".
Step 2: Declaring the DLL
To use a DLL written in Visual Basic in your WINDEV project, this DLL must be declared in the process that is using it. This DLL must be declared as Automation object. For more details, see Automation object
<VariableName> is object OLE "<nameofVBproject>.<nameofVBmodule>"
MyVisualBasicDLL is object OLE "MyProject.MyModule"
Step 3: Handling the DLL
The DLL can be handled like any Automation object (for more details, see Automation object
). The calls to the methods and properties are performed as follows:
[ReturnValue = ] VariableName>>Function()
[ReturnValue = ] VariableName>>Function(Parameter1 [,Parameters [,...]])
// Call to the QueryUser method
Value is string = MyVisualBasicDLL>>QueryUser()
// Call to the DisplayInfo method
MyVisualBasicDLL>>DisplayInfo("This is a test")
Step 4: Freeing the DLL
This step is optional. Indeed, the DLL will be automatically freed when the application or the window that handles the DLL is closed.
To free the DLL, use the following syntax:
// Free the VB DLL