DLL Class
The DLL class provides the ability to communicate with a Microsoft Windows dynamic-link library (DLL).
Syntax
class DLL extends Object
Run On
Called
Methods
Method | Description | |
---|---|---|
cancelTimeOut | Cancels a previous method call to the setTimeOut method. (Inherited from Object.) | |
equal | Determines whether the specified object is equal to the current one. (Inherited from Object.) | |
finalize | Releases resources and performs clean-up before an instance of the DLL class is released. | |
getTimeOutTimerHandle | Returns the timer handle for the object. (Inherited from Object.) | |
handle | Retrieves the handle of the class of the object. (Inherited from Object.) | |
new | Creates an instance of the class. (Overrides the new Method.) | |
notify | Releases the hold on an object that has called the wait method on this object. (Inherited from Object.) | |
notifyAll | Releases a lock on the object that was issued by the wait method on this object. (Inherited from Object.) | |
objectOnServer | Determines whether the object is on a server. (Inherited from Object.) | |
owner | Returns the instance that owns the object. (Inherited from Object.) | |
setTimeOut | Sets up the scheduled execution of a specified method. (Inherited from Object.) | |
toString | Returns a string that represents the current object. (Inherited from Object.) | |
usageCount | Returns the current number of references, that is, the value of the reference counter, that the object has. (Inherited from Object.) | |
wait | Pauses a process. (Inherited from Object.) | |
xml | Returns an XML string that represents the current object. (Inherited from Object.) | |
::lastDLLError | Sets or retrieves the last error that was reported by the DLL. |
Top
Remarks
If you are using a Unicode DLL, do the following:
Use ExtTypes::WString instead of ExtTypes::String to specify a string type.
Use Binary::WString instead of Binary::String if you have character data embedded in a binary structure.
Use the Binary.wstring method instead of the Binary.string method if you need to read a string from a binary object.
ExtTypes::WString Example (Code Example Removed) Binary.wString Example (Code Example Removed)
Examples
The following example uses the DLL and the DLLFunction classes to interoperate with the GetVersion API in Kernel32.dll. The example asserts the use of the InteropPermission class, which is only needed if the code is running on the server. It loads the DLL, and, if it is successful, it sets the return type from the call to the DLLFunction class.
void DLLExample()
{
Dll dll;
DllFunction dllFunc;
anytype retVal;
InteropPermission perm;
perm = new InteropPermission(InteropKind::DllInterop);
// Grants permission to execute the DLL.new method.
// DLL.new runs under code access security.
perm.assert();
dll = new Dll("Kernel32.dll");
// Closes the code access permission scope.
CodeAccessPermission::revertAssert();
if (dll != null)
{
perm = new InteropPermission(InteropKind::DllInterop);
// Grants permission to execute the DLLFunction.new method.
// DLLFunction.new runs under code access security.
perm.assert();
dllFunc = new DllFunction(dll, "GetVersion");
if (dllFunc != null)
{
dllFunc.returns(ExtTypes::DWord);
retVal = dllFunc.call();
}
// Closes the code access permission scope.
CodeAccessPermission::revertAssert();
}
}
Inheritance Hierarchy
Object Class
DLL Class