Hello,
I'm trying to do something special in QlikView Desktop and need your help …
I want to call (in my script) a Function() stored in a DLL.
In this simple example, the called function returns the “DoubleClickTime” which is a NUMBER in milliseconds.
The function is stored in "user32.dll" and is called "GetDoubleClickTime()".
I've read it's mandatory to use a wrapper (eg DynamicWrapperX in my case) to load a DLL in VBScript.
It's one of the big diffences between VB/VBA and VBScript ...
My QV sript (CTRL+E):
DATA:
LOAD
'TOTO' AS F1
,Test() AS F2
,AddOne(100) AS F3
AutoGenerate(1);
My QV module (CTRL+M):
Function AddOne(Val)
AddOne = Val + 1
End Function
'--
Function Test()
Dim DWX
Set DWX = CreateObject("DynamicWrapperX")
DWX.Register "user32.dll", "GetDoubleClickTime", "r=u"
Test=DWX.GetDoubleClickTime
End Function
test.qvw application is attached to this discution.
After reloading the application, my result is a table named DATA having one line:
Addone() is a very simple function used to validate that calling a VBScript function in a script work. And it works well.
Test() is more complicated, and doesn’t work. It return a null() value rater than "500" wich is the expected result.
I’m using a wrapper (DynamicWrapperX 2.1.1.1) to call "GetDoubleClickTime()" function which is stored in "user32.dll".
Easy, isn't it ?
The Test() function has been tested in a simple VBScript named “test.vbs” lookink like this :
wscript.echo "DoubleClickTime is " & Test & " ms"
Function Test()
Dim DWX
Set DWX = CreateObject("DynamicWrapperX")
DWX.Register "user32.dll", "GetDoubleClickTime", "r=u"
Test=DWX.GetDoubleClickTime
End Function
test.vbs script is attached to the discution.
I’ve registred the DynamicWrapperX DLL with administrator privileges.
Using cmd.exe (opened with admin account) :
C:\...\>regsvr32 dynwrapx.dll |
Execute the script using cmd.exe (with administrator privileges):
C:\...\>cscript test.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. Tous droits réservés.
DoubleClickTime is 500 ms
|
The result is good Thus it should work in QlikView, isn't it ? But it don't
Where is the problem in QlikView ???
Any suggestion is welcome ...
I've remark several things:
- There's nothing special in the QV application logs. No Error.
- In QV 'Edit Module', when I test my Test() function, i receive this message : ActiveX component can't create object: 'DynamicWrapperX'
- ActiveX component can't create object: 'DynamicWrapperX' message appears when I call 'cscript test.vbs' and if I haven't registred the DynamicWrapperX in Windows (regsvr32 dynwrapx.dll).
- I've to be administror to execute the test.vbs script. Otherwise I have the error message : ActiveX component can't create object: 'DynamicWrapperX'. Why ? I don't know
- I've to be administror too, to register the dll. Otherwise I have the error message : ActiveX component can't create object: 'DynamicWrapperX'
I've tried a lot of things that don't work:
- Using full dll path when calling CreateObject() --> ActiveX component can't create object: 'DynamicWrapperX'
- Copying the DLL in the QV DLL folders & binary folders, in System32 folder too ... --> ActiveX component can't create object: 'DynamicWrapperX'
- Opening/reloading the application with administrator account. It doesn't change anything ... --> ActiveX component can't create object: 'DynamicWrapperX'
- A lot of little things ... --> ActiveX component can't create object: 'DynamicWrapperX'
- Drinking beers & tea ... --> ActiveX component can't create object: 'DynamicWrapperX'
My sources :
Why am I doing that ?
Because the use of DLL hugely opens opportunities to QlikView. Like IBAN validation (too complex in QV script), encryption capability (not a simple hashing), complex transformations using C/C++/VB/... functions, ..., to go on the moon perhaps
Many thanks for reading me. Even more for helping me ... -
Julien