PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Overview
  • Use
  • 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
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Calling a DLL written in Visual Basic
Overview
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).
Caution: In a WINDEV application, these specific DLLs cannot be called by API or CallDLL32. Indeed, these DLLs do not comply with the WINAPI standard of Windows. These DLLs are used in the WINDEV projects as automation objects. See Automation objects for more details.
Use

Using a Visual Basic DLL

To use a DLL written in Visual Basic in a WINDEV project:
  1. Register the DLL if necessary.
  2. Declare the DLL in a WLanguage process.
  3. Handle the DLL as an OLE object.
  4. 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 uses it. This DLL must be declared as Automation object. See Automation object for more details.
<VariableName> is object OLE "<nameofVBproject>.<nameofVBmodule>"
For example:
MyVisualBasicDLL is object OLE "MyProject.MyModule"

Step 3: Handling the DLL

The DLL can be handled like any Automation object (see Automation object for more details). The calls to the methods and properties are performed as follows:
Without parameter:
[ReturnValue = ] VariableName>>Function()
With parameters:
[ReturnValue = ] VariableName>>Function(Parameter1 [,Parameters [,...]])
For example:
// 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

The DLL is freed like any Automation object, via the Delete keyword. See Automation object for more details.
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:
delete <VariableName>
For example:
// Free the VB DLL
delete MyVisualBasicDLL
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment