Sign in to follow this  
Followers 0

RegFreeCOM Example - Part II

4 posts in this topic

Posted (edited)

RegFreeCOM Example - Part II

Since my first attempt to distribute 2007, life got harder to accomplish this. Because since Vista, Microsoft has changed the way how it was done.

But since the existance of AutoiITOO trancexx ( _AutoItObject_ObjCreateEx ) opened a new possibiltity to do this in a very simple way, by just calling the CLSID of the COM Object.

Now he/she implemented this feature in native AU3 since the last Beta 3.3.9.1 thanks for that :oops:

Here is an Example that shows you how to use it.

I choose KixForms.dll as an example.

Because it had nearly no examples posted here in AU3, and because the syntax is very simular to AU3.

You can download v2.46 here together with an nice HELP chm file.

#AutoIt3Wrapper_UseX64=N

Global $hActiveX
; Load the COM server module
$hActiveX  = DllOpen(@ScriptDir & "kixforms.dll")

; Object identifiers
Global Const $sCLSIDApp = "{18F66832-6A94-4D70-B7EA-C51ACA6092A4}"
Global Const $sIIDApp =  Default ; "{04E9D874-6E55-4DAB-A7EC-77F803A15E70}"
Global Const $sCLSIDSystem = "{FEEC1680-5609-4A96-847D-4585CEB24ED4}"
Global Const $sIIDSystem =  Default
Global Const $sCLSIDForm = "{F89DF848-618A-46F9-8A1C-396EA442BDD3}"
Global Const $sIIDForm =  Default
Global Const $sCLSIDDialog = "{C9A8E0D2-1D16-4EA4-9EA4-54F08D9C0D17}"
Global Const $sIIDDialog =  Default

; 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


$KixSystem = ObjCreate($sCLSIDSystem,$sIIDSystem,$hActiveX)
;$KixSystem = ObjCreate("KiXtart.System")

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

Global $Form = $KixSystem.Form
Global $Exit = $Form.ToolButton

With $Form
	.FontName = "Tahoma"
	.FontSize = 10
EndWith

Global $SmallIcon = $Form.ToolButton
With $SmallIcon
	.Location = $KixSystem.Point(10, 10)
	.Width = 23
	.Icon = 40
	;.OnClick = "$ListView.View = 1"
.OnClick = "ListView_View(1)"

	.FlatStyle = 1
EndWith

Global $LargeIcon = $Form.ToolButton
With $LargeIcon
	.Location = $KixSystem.Point($SmallIcon.Right + 5, 10)
	.Width = 23
	.Icon = 38
	;.OnClick = "$ListView.View = 0"
.OnClick = "ListView_View(0)"
	.FlatStyle = 1
EndWith

Global $ListIcon = $Form.ToolButton
With $ListIcon
	.Location = $KixSystem.Point($LargeIcon.Right + 5, 10)
	.Width = 23
	.Icon = 39
	;.OnClick = "$ListView.View = 2"
.OnClick = "ListView_View(2)"
	.FlatStyle = 1
EndWith

Global $DetailsIcon = $Form.ToolButton
With $DetailsIcon
	.Location = $KixSystem.Point($ListIcon.Right + 5, 10)
	.Width = 23
	.Icon = 41
	;.OnClick = "$ListView.View = 3"
.OnClick = "ListView_View(3)"
	.FlatStyle = 1
EndWith

Global $ListView = $Form.ListView
With $ListView
	.Location = $KixSystem.Point(10, $SmallIcon.Bottom + 10)
	.Right = $Form.ClientWidth - 10
	.Bottom = $Form.ClientHeight - 35
	.Columns.Count = 1
	.SmallImageList = $Form.SmallImageList
	.OnClick = "ListView_Click()"
	.View = 0
EndWith

$LargeImageList = $Form.ImageList
With $LargeImageList
	.ImageSize = $KixSystem.Size(32, 32)
	For $i = 0 To $Form.SmallImageList.Images.Count
		.Images.Add($Form.SmallImageList.Images($i))
	Next
EndWith

$ListView.largeImageList = $LargeImageList

Func ListView_View($x)
$ListView.View = $x
;ConsoleWrite($x & @CRLF)
EndFunc

Func ListView_Click()

	$Exit.Icon = $ListView.SmallImageList.Images($ListView.FocusedItem.Text)
EndFunc

For $i = 0 To $ListView.SmallImageList.Images.Count
	$Item = $ListView.Items.Add($i,$i)
Next


With $Exit
	.Center()
	.Top = $ListView.Bottom + 10
	.Text = "Exit"
	.Icon = 37
	.OnClick = "Quit()"
EndWith

$Form.Center()
$Form.Show()

While $Form.Visible
	Execute($Form.DoEvents)
Wend

Exit 1 

Enjoy !

ptrex

Edited by ptrex

Share this post


Link to post
Share on other sites



Posted

@ptrex:

Thank you. I had problem to view the KiXforms_246.chm content.

Recompiled KiXforms_246_fixed_by_VI.chm is workin help for KixForm, though.

You can download it from my autoitgroup:

http://tech.groups.yahoo.com/group/autoitgroup/message/141

Share this post


Link to post
Share on other sites

Posted

@ValeryVal

Mostlike this is not a problem with the CHM file but it is your security setting on the machine.

If opening the CHM file you don't see the content, right click it go to security and say ALLOW -> fixed.

This is standand windows behaviour for untrusted CHM files.

Rgds

ptrex

Share this post


Link to post
Share on other sites

Posted

Mostlike this is not a problem with the CHM file but it is your security setting on the machine.

Maybe. However this is a first untrusted CHM file and it would be better recompile it into trusted one.

:oops:

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  
Followers 0