Jump to content
Sign in to follow this  
Matrix112

Using a COM property out of not registered DLL?

Recommended Posts

Matrix112

Hi,

for some of my Scripts i need a function to change some file properties. I have downloaded a .dll file from Microsoft with the function i need. Now my problem: It is a COM function.

How can i call it without the need, to register the dll? Is it possible?

I tried to translate some VB code (only working with registered DLL):

Set oFile = CreateObject("DSOFile.OleDocumentProperties")
oFile.Open("c:\tmp\test.txt")
oFile.SummaryProperties.Comments = "Test Comment"
oFile.Save
oFile.Close

Now my Script:

$dll = DllOpen("dsofile.dll")
$oFile = ObjCreate("DSOFile.OleDocumentProperties")
If Not @error Then
MsgBox(4096, "ObjCreate Test", "ObjCreate() of a DSO File Object successful !")
Else
MsgBox(4096, "ObjCreate Test", "Failed to create Object. Error code: " & Hex(@error, 8))
EndIf
DllClose($dll)
Exit

If i run the script above, i get the error code: 800401F3

This semms to be "Object not found" or something similar.

Maybe i can call the function out of the DLL with dllcall, but how?

I used DLL Export Viewer to get the following information (not all functions in this dll file):

Function names:

_OleDocumentProperties::Close

_OleDocumentProperties::CLSID

_OleDocumentProperties::IsOleFile

_OleDocumentProperties::Open

_OleDocumentProperties::Save

CustomProperties::Add

CustomProperty::Remove

SummaryProperties::Comments

I´m not very familiar with dllcall and com objects, so maybe someone knows how to do it?

Share this post


Link to post
Share on other sites
trancexx

There is experimental feature available in some latest versions of AutoIt that allows you to create COM objects from modules without any demand on user to register anything.

It would be something like this:

; Object identifiers
Global Const $sCLSID_OleDocumentProperties = "{58968145-CF05-4341-995F-2EE093F6ABA3}"
Global Const $IID_OleDocumentProperties = "{58968145-CF01-4341-995F-2EE093F6ABA3}"

$sDll = "dsofile.dll" ; location and name of your dll
$hDll = DllOpen($sDll) ; open it

; Experimenal feature. Try with newer versions of AutoIt
$oObj = ObjCreate($sCLSID_OleDocumentProperties, $IID_OleDocumentProperties, $hDll)

; Check for errors and work with object
;...
Edited by trancexx
  • Like 2

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Matrix112

There is experimental feature available in some latest versions of AutoIt that allows you to create COM objects from modules without any demand on user to register anything.

It would be something like this:

; Object identifiers
Global Const $sCLSID_OleDocumentProperties = "{58968145-CF05-4341-995F-2EE093F6ABA3}"
Global Const $IID_OleDocumentProperties = "{58968145-CF01-4341-995F-2EE093F6ABA3}"

$sDll = "dsofile.dll" ; location and name of your dll
$hDll = DllOpen($sDll) ; open it

; Experimenal feature. Try with newer versions of AutoIt
$oObj = ObjCreate($sCLSID_OleDocumentProperties, $IID_OleDocumentProperties, $hDll)

; Check for errors and work with object
;...

That works, thank you :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×