Jump to content

RegFreeCOM Au3X Example


ptrex
 Share

Recommended Posts

RegFreeCOM Au3X Example

Some time ago, someone in the support forum was asking if it is possible to distribute COM DLL's, on different machines, and not registering them.

Well infact it is possible, using the MS SxS Manifest approach.

For those who don't know what SxS is, it's an other word for ESCAPING DLL HELL :

Quote

Windows XP introduces a new COM activation model called registration-free COM, or Reg-Free COM for short. Simply stated, Reg-Free COM is a registry replacement for COM components. It works by expressing all of the standard component registration information that is typically installed into the system registry in a file that can be stored in the same folder as the application itself.

More information on how to build RegFreeCOM Manifest files, look here : Simplify App Deployment with ClickOnce and Registration-Free COM

Download this example.

RegFreeCOM_Au3X_Example.zip

Save it to a machine running at least XP, and don't register any AutoItX3.dll.

Run the "RegFreeCOM_Au3X_Example.exe" and see what happenes.

Copy it to an other machine an try again. You will see that you are liberated from DLL registration as of now.

The SxS technique is using an XML Manifest file to replace the need to use "regsvr32" for registering the COM objects.

For those who remember my example on how to create COM objects, without the need of a DLL.

This is next complimentary technique,l that allow you to create, run and distribute COM objects, by just distributing some files.

This is an other example :

Make sure no Au3X.Dll is installed on that machine. Or run : regsvr32 "C:\Program Files\AutoIt3\AutoItX\AutoItX3.dll" /u

In order to run this -> Compile the code to RegFreeCOM_Au3X_Example.exe

And put it in the same folder as where the Manifest files are located. (Can be a USB stick)

$oAutoIt = ObjCreate("AutoItX3.Control.1")
$oAutoIt.Run("notepad.exe")
;Wait for the window "Untitled" to exist and be active
$oAutoIt.WinWaitActive ("Untitled")

$oAutoIt.Send("{Enter}")
$oAutoIt.Send("This is an example of : ")
$oAutoIt.Send("{Enter}")
sleep(500)
$oAutoIt.Send("How to get rid of the need of the registry,")
$oAutoIt.Send("{Enter}")
sleep(1000)
$oAutoIt.Send("in order to run COM object like Au3X.dll")
$oAutoIt.Send("{Enter}")
sleep(1000)
$oAutoIt.Send("{Enter}")
$oAutoIt.Send("{Enter}")
$oAutoIt.send("Enjoy!")

 

See here for more REGFREE examples tested on different platforms :

https://www.autoitscript.com/forum/topic/204813-use-autoitx-as-com-rot-object-without-regsvr32-registration/?do=findComment&comment=1472426

https://www.autoitscript.com/forum/topic/204813-use-autoitx-as-com-rot-object-without-regsvr32-registration/?do=findComment&comment=1472602

 

Enjoy !!

ptrex

Edited by ptrex
Link to comment
Share on other sites

RegFreeCOM Au3X Example

Some time ago, someone in the support forum was asking if it is possible to distribute COM DLL's, on different machines, and not registering them.

Well infact it is possible, using the MS SxS Manifest approach.

For those who don't know what SxS is, it's an other word for ESCAPING DLL HELL :

More information on how to build RegFreeCOM Manifest files, look here : Simplify App Deployment with ClickOnce and Registration-Free COM

Download this example.

RegFreeCOM_Au3X_Example.zip

Save it to a machine running at least XP, and don't register any AutoItX3.dll.

Run the "RegFreeCOM_Au3X_Example.exe" and see what happenes.

Copy it to an other machine an try again. You will see that you are liberated from DLL registration as of now.

The SxS technique is using an XML Manifest file to replace the need to use "regsvr32" for registering the COM objects.

For those who remember my example on how to create COM objects, without the need of a DLL.

This is next complimentary technique,l that allow you to create, run and distribute COM objects, by just distributing some files.

Enjoy !!

ptrex

GREAT !!!

i love to see that this is possible, even on a win2000 machine.

btw: could you look into the WinPCap problem i have with packet.dll can need your help :)

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

Ok, I see an icon in the title bar that is not the one used to compile and a run notepad button. Click on the run notepad and notepad opens. Without sharing the source code this is all I can see working. Notepad works from any old button.. LOL Care to share? :)

edit: typo

Edited by gesller
Link to comment
Share on other sites

@all

Most of you will know WinPE or BartPE (running Windows from a bootable CD)

Well those of you who have BartPE on the machine should look for *.Manifest files.

And you wiill see that that's the secret to liberate you from the Registry, when running DLL's.

So what I tested is this :

1. I Unregistered the Au3X COM DLL -> regsvr32 "C:\Program Files\AutoIt3\AutoItX\autoitx3.dll" /u

2. I copied the files from the 1st post, to a USB memory stick. And run the application.

So as of know you can run the Au3X anywhere anyplace.

Enjoy !!

ptrex

Link to comment
Share on other sites

Link to comment
Share on other sites

@gesller

That is one of the advantages of RegFreeCOM Dll's.

Here are some more :

The benefit of describing components in the system registry is that it enables them to be shared among multiple applications. It's also possible to register a component such that it can be installed and activated on another machine over the network.

If your application is not using any of these capabilities, then this global machine registration can also be a huge liability for your application. First, ensuring every component is properly registered usually requires the overhead of a separate setup program, such as an MSI or EXE installer. Also, component registration may involve anywhere from dozens to thousands of registry keys, depending on the size of the component.

If any one of these entries is corrupted, it can cause the application to fail. Having applications, components, and registration scattered all over the machine can make it very hard to properly manage application updates and uninstallation, particularly if some of the components are shared between multiple applications. This is probably COM's most prevalent problem as it makes some components and applications extremely fragile and difficult to maintain.

So lookking at it the opposite way, AU3 can use "Manifest" COM objects without a need of a Registry.

Example might be that you want to writ a SQLiteX database application and distribute it. But the downsite is that each client needs to register the SQLiteX DLL on the client.

Using a SQLiteX.Manifest file solves the problem of registering it on each client. It will run as it is without the need of a registration in the registry.

I hope this clarifies it a bit more.

Regards,

ptrex

Link to comment
Share on other sites

@All

Updated the first post with a more visible example for the AU3 users.

Regards,

ptrex

Looks good but you might want to try editing this part of your first post

Or run : regsvr32 "C:\Program Files\AutoIt3\AutoItX\AutoItX3.dl"l /u

to get the closing quote in the right place. Just in case someone decides to copy/paste it.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 1 year later...
  • 4 years later...
  • 4 weeks later...

This looks so promising! I've been trying to interface with a comvisible=false .NET DLL for quite some time now with no luck.

I've tried reading through the MSDN resources on the topic, but I'm a little confused as where to get started...

Any advice on how to create the manifest and required files for this technique from a DLL?

Is there an easy way to view/browse the methods within the DLL that have become ready for use?

PTrex your work is really impressive! Thanks!~

Link to comment
Share on other sites

@ShawnJ007

This is a +5 year old topic, so things have changed over time !

First of all there are 2 unrelated questions coming from you :

1. RegFree SxS technique has been changed by MS because of security since the version Vista and higher.

Making this very hard to if not impossible to work. But don't worry because trancexx has added this feature native to AutoIT.

Just reference the CLID in the objcreate like here

....
; Object identifiers
Global Const $sCLSID = "{1A671297-FA74-4422-80FA-6C5D8CE4DE04}"
;Global Const $sIID = "{3D54C6B8-D283-40E0-8FAB-C97F05947EE8}"
Global Const $sIID = Default
.....
; Create the hActiveX
Local $oAutoIt = ObjCreate($sCLSID, $sIID, $hActiveX)

I am not sure whether this is mentioned in the help file somewhere, best test it using the Beta version AU3.

2. How to view / Methods / properties in a DLL :

See here for a perfect solution created by trancexx called TypeLib Viewer

Rgds,

ptrex

Link to comment
Share on other sites

@ptrex:

I believe that you have in mind

; Create the hActiveX 
Local $oAutoIt = ObjCreateInterface($sCLSID, $sIID, $hActiveX)

instead of

; Create the hActiveX 
Local $oAutoIt = ObjCreate($sCLSID, $sIID, $hActiveX)

Is it truth?

The point of world view

Link to comment
Share on other sites

No not realy ?

But as I said you can only use it in the autoIT Beta 3.3.9.4 and higher I guess ?

Here is a full working example

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=Y

Global $hActiveX

; Load the server module
If @AutoItX64 Then
    $hActiveX = DllOpen(@ScriptDir & "\AutoItX3_x64.dll")
Else
    $hActiveX = DllOpen(@ScriptDir & "\AutoItX3.dll")
EndIf
;MsgBox(0,"x64",@AutoItX64)

; Object identifiers
Global Const $sCLSID = "{1A671297-FA74-4422-80FA-6C5D8CE4DE04}"
;Global Const $sIID = "{3D54C6B8-D283-40E0-8FAB-C97F05947EE8}"
Global Const $sIID = Default ; Or use keyword Default if you want to use the Default interface ID

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF)
    Return
EndFunc ;==>_ErrFunc

; Create the hActiveX
Local $oAutoIt = ObjCreate($sCLSID, $sIID, $hActiveX)

If $oAutoIt = 0 Then MsgBox(16,"Error", "Could not create the object, Common problem ActiveX not registered.")

; This will create a tooltip in the upper left of the screen
$oAutoIt.ToolTip ("This is a tooltip", 550, 600)
$oAutoIt.Sleep (3000)   ; Sleep to give tooltip time to display

;Sleep(1000)

$oAutoIt = ""
DllClose($hActiveX)

Rgds

ptrex

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...