Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

RegFreeCOM Au3X Example


  • Please log in to reply
16 replies to this topic

#1 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 27 September 2007 - 02:14 PM

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 :

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.
Attached File  RegFreeCOM_Au3X_Example.zip   159.3KB   2510 downloads

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 FilesAutoIt3AutoItXAutoItX3.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!")



Enjoy !!

ptrex

Edited by ptrex, 15 March 2012 - 02:59 PM.

  • yahaosoft likes this







#2 JRSmile

JRSmile

    IT infrastructure specialist

  • Active Members
  • PipPipPipPipPipPip
  • 455 posts

Posted 27 September 2007 - 02:23 PM

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.
Attached File  RegFreeCOM_Au3X_Example.zip   159.3KB   2510 downloads

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:-)Try2Hack: http://www.try2hack.nl/levels/level13-olwehfdow.xhtml

#3 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 27 September 2007 - 06:47 PM

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, 27 September 2007 - 06:47 PM.


#4 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 27 September 2007 - 06:52 PM

@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

#5 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 27 September 2007 - 06:55 PM

@gesller

Open the "RegFreeCOM_Au3X_Example.exe.manifest" in Notepad and you will see the source.

But without reading the background info I linked in the 1st post. It won't tell you much will it ?!

regards,

ptrex

#6 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 27 September 2007 - 07:12 PM

Aha! I see. using the manifest to overide reg. Sweet! That will open the door to make many more portable apps.. Cool!

#7 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 27 September 2007 - 07:58 PM

@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

#8 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 27 September 2007 - 08:06 PM

You do write some sweet code!
Thanx

#9 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 28 September 2007 - 01:02 PM

@All

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

Regards,

ptrex

#10 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 28 September 2007 - 01:56 PM

@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.
GeorgeQuestion 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!"

#11 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 28 September 2007 - 03:34 PM

@GEOSoft

Thanks for noticing. :)

Fixed in the first post.

regards

ptrex

#12 toxicvn

toxicvn

    Wayfarer

  • Active Members
  • Pip
  • 94 posts

Posted 24 October 2008 - 01:54 PM

thank :( :P

#13 yahaosoft

yahaosoft

    Seeker

  • Active Members
  • 18 posts

Posted 11 November 2012 - 10:48 AM

thank you very much!
I used it in my project and worked well. :ILA2:
Thanksgiving...

#14 ShawnJ007

ShawnJ007

    Seeker

  • Active Members
  • 8 posts

Posted 09 December 2012 - 03:58 PM

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!~

#15 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 11 December 2012 - 06:22 AM

@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 http://www.autoitscript.com/forum/topic/116735-typelib-viewer/page__hl__+typelib%20+viewer#entry863478



Rgds,
ptrex

#16 ValeryVal

ValeryVal

    Dig the way

  • Active Members
  • PipPipPipPipPipPip
  • 439 posts

Posted 12 December 2012 - 07:36 AM

@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

#17 ptrex

ptrex

    Universalist

  • MVPs
  • 2,408 posts

Posted 12 December 2012 - 04:18 PM

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

AutoIt         
#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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users