Page 1 of 1

[AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 04 May 2015, 08:27
by tmplinshi
http://hotkeyit.github.io/v2/docs/comma ... ObjDll.htm

I'm confused. Isn't ComObjDll designed for creating COM Object from a unregistered COM dll?

But below script prompt "0x8002801D - Library not registered" error message.

Code: Select all

hModule := DllCall("LoadLibrary", "Str", "xd2txcom.dll")
obj := ComObjDll(hModule, "{4ECE8E8A-BCC2-4709-BCAE-264210DF321B}") ; Have tried "xd2txcom.Xdoc2txt.1" and "xd2txcom.Xdoc2txt" too.
fileText := obj.ExtractText("sample.doc", False)
MsgBox % fileText
vbs sample by the xd2txcom.dll author: (Of cause, this will need to register xd2txcom.dll first.)

Code: Select all

Set obj = CreateObject("xd2txcom.Xdoc2txt.1")

Dim fileText
fileText = obj.ExtractText("sample.doc",False)

MsgBox fileText
testing files: https://www.dropbox.com/s/samiybf94b3ef ... 9.7z?raw=1

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 04 May 2015, 16:03
by HotKeyIt
When I try to register the dll I get the error:
The module "...\xd2txcom.dll" was loaded but the call to DllRegisterServer failed with error code 0x80070005.
ComObjDll works same as ComObjCreate but the dll does not need to be registered.
E.g. try using AutoHotkey.dll without registering.


Can you provide a working example in any other language using xd2txcom.dll?

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 00:58
by tmplinshi
ahh, you were right, this dll file is not working even when it has registered to system (using regsvr32 xd2txcom.dll). Sorry I didn't have a try.

I'll try other versions of this dll, to see if it works. The official website is http://ebstudio.info/home/xdoc2txt.html.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 01:07
by tmplinshi
Found a note in the README.txt, on 64bit OS the usage is:

Code: Select all

C:\Windows\SysWOW64\cscript.exe comtest.vbs

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 01:17
by HotKeyIt
Could you get it to run?
When I run, I get an error:
Microsoft VBScript runtime error: ActiveX component can't create object: 'xd2txcom.Xdoc2txt.1'

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 01:21
by tmplinshi
Yes, it works for me. But need to call by using C:\Windows\SysWOW64\cscript.exe comtest.vbs. double-click the vbs produce the same error as you get.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 01:23
by HotKeyIt
So it works on 64-bit only? Did you try 64-bit AutoHotkey?

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 01:29
by tmplinshi

Code: Select all

obj := ComObjCreate("xd2txcom.Xdoc2txt.1")
fileText := obj.ExtractText("sample.doc",False)
MsgBox % fileText
My OS is win7 64bit, this code works in AutoHotkey A32 and U32, but not U64.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 03:36
by HotKeyIt
That is because the dll is 32-bit I think, but I am not sure.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 04:00
by lexikos
One DLL cannot be both 32-bit and 64-bit. Unless you've registered two separate DLLs, one in the 32-bit section of the registry and one in the 64-bit, it cannot work on both.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 09:45
by tmplinshi
@lexikos
After some registry modifies by following the steps from this article, it works in A32, U32 and U64. And still only one DLL.

Code: Select all

; Register the dll
dllFile := A_ScriptDir "\xd2txcom.dll"
RunWait, regsvr32 /s "%dllFile%"

; http://www.gfi.com/blog/32bit-object-64bit-environment/
GUID := "{4ECE8E8A-BCC2-4709-BCAE-264210DF321B}"
RegWrite, REG_SZ, HKCR, % "Wow6432Node\CLSID\" . GUID     , AppID       , % GUID
RegWrite, REG_SZ, HKCR, % "Wow6432Node\AppID\" . GUID     , DllSurrogate, % ""
RegWrite, REG_SZ, HKLM, % "Software\Classes\AppID\" . GUID

; Now it should work on all versions (A32/U32/U64) of AutoHotkey
obj := ComObjCreate("xd2txcom.Xdoc2txt.1")
fileText := obj.ExtractText(A_ScriptDir "\sample.doc", False)
MsgBox % fileText
@HotKeyIt
Would you consider that as a bug to AHK_H? Since ComObjCreate works fine when the COM dll is registered. Or could you provide a way to make ComObjDll works? Thanks!

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 12:14
by HotKeyIt
tmplinshi wrote:Would you consider that as a bug to AHK_H? Since ComObjCreate works fine when the COM dll is registered. Or could you provide a way to make ComObjDll works? Thanks!
Do you mean to load a 32-bit dll from 64-bit AutoHotkey using ComObjDll?
This is not possible as I understand. Probably you could load it using dllhost but I am not sure how.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 19:57
by tmplinshi
No, load a 32-bit dll from 32-bit AutoHotkey using ComObjDll, but should support x86 and x64 OS.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 20:18
by lexikos
tmplinshi wrote:@lexikos
After some registry modifies by following the steps from this article, it works in A32, U32 and U64. And still only one DLL.
I stand corrected. The key here is that the DLL is not loaded into the AutoHotkey process directly, but instead loaded into a DLL surrogate proccess.

However, that sort of technique couldn't possibly work with ComObjDll, since you have to load the DLL into the current process first.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 05 May 2015, 21:10
by tmplinshi
Thanks, lexikos. I don't know much about programming.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 07 May 2015, 20:47
by tmplinshi
HotKeyIt wrote:When I try to register the dll I get the error:
The module "...\xd2txcom.dll" was loaded but the call to DllRegisterServer failed with error code 0x80070005.
OK, I get this error too, on windows XP x86.

But then I've tried another dll XImage, the ComObjDll didn't work on x86 and x64 OS.

Code: Select all

; https://www.dropbox.com/s/5ky068zs63364yx/XImage_test.7z?raw=1
hModule := DllCall("LoadLibrary", "Str", A_ScriptDir "\XImage.dll")
img := ComObjDll(hModule, "{DBE17C44-B996-4245-8031-5984FB09FE0F}")
img.Load(A_ScriptDir "\test.jpg")
MsgBox, % img.Width

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 08 May 2015, 07:07
by HotKeyIt
Looking at the error this dll must be registered if I understand right.
It also requires admin privileges but not sure if this is relevant.

Re: [AHK_H]Creates a COM Object from a unregistered COM dll?

Posted: 10 May 2015, 06:38
by tmplinshi
Thanks for your help, HotKeyIt. So far I only get ComObjDll working with AutoHotkey.dll. I'll find more COM dlls to test, maybe ComObjDll is only working for AutoHotkey.dll.