Calls to "_class::property" stuff

Recommended Posts

Well I asked it before in an other topic but no one replies there so I thought I'll start it as a seperate topic.

Ok I'm kinda stuck & hope somebody can help me with this here.

I'm following this tutorial but I can't get stuff to work.

I have a dll & it has like COM Properties or idk like "_class::propperty" but how do I call them?

using DLLCall (like I tried) or do I need the ObjGet function? Or both of them combined?

I haven't used dll's & com stuff before but now I need to and now this tutorial did help me understand DLLCall better.

Anybody can push me in the right direction? Do I need DLLCall or ObjGet or both? And how do I use those things from the dll (those that look like "_class::property") in AutoIt?

Edit: I also found a function called "DllGetClassObject" in the dll, can I use that to create an object and then use that to call the properties? If so how?

When I tried it myself it crashed with exit code -1073741819.

Edit: I now noticed some of them are methods and others properties, can I both use methods and get properties?

Edited by 1RV34
MsgBox(0x40040, "", "Hello Forum!")
Share on other sites
• 2 weeks later...

Using a DLL viewer I saw these functions:

• DllGetClassObject
• DllRegisterServer
• DllUnregisterServer
Which indicate I can register the DLL using
regsvr32 "C:pathtothedll.dll"
and I think I should then be able to use ObjCreate("obj.type") to continue.

But how do I find that "obj.type" and then call to "_clsClass::mtdMethod" & "_clsClass::prpProperty"?

I'm really stuck and any hint or push in the right direction would help a lot :/

MsgBox(0x40040, "", "Hello Forum!")
Share on other sites

hi 1RV34,

ObjCreate is fine for COM objects.

Unfortunately you gave us very little (relevant, specific) information so that's about all the help I can offer at the moment.

What is the name of the dll? Where can one find it? and its documentation?

Also, please post the code you tried, and any errors you might have encountered.

-smartee

Share on other sites

If the COM dll was compiled with type information you should be able to load it into a Type Library Viewer to see the supported interfaces. Basically if the library is really an ActiveX Control or has Automation support, you can load from a scripting language. Otherwise if it's virtual method table only, you need to access it from a compiled language. If it supports Automation chances are it has a Type Library. So try a Type Library viewer. I'm sure you can download a free one someplace.

It's been quite a few years since I did COM programming. So this is just from vague memory. Hope I pointed you in the right direction.

Share on other sites

What is the name of the dll? Where can one find it? and its documentation?

The name is "SnelStartGateWay.dll". It is ment to make communication between your program and SnelStart possible.

It can be found in "C:Program Files (x86)SnelStartV1000" (V1000 is version dependable but my script finds the right path). It comes with the program.

The documentation is in Dutch so I don't know if that will help you much, but what I can do is give the (vb6) example in it if that might help.

Private Sub mtdToevoegenJournaalPost()
On Error GoTo ErrorHandler
'Declaratie variabelen
Dim mvrGWaySnelStart As clsGWaySnelStart
Dim mvrGbOmschrijving As String
'Aanmaken nieuwe ToegangsObject
Set mvrGWaySnelStart = New clsGWaySnelStart
With mvrGWaySnelStart
'Uitlezen of Administratie in Euro's is
'Uitlezen omschrijving van Grootboek 9990
mvrGbOmschrijving = .mtdGWayGrootboekOmschrijving(9990)
Debug.Print "Omschrijving van GrootBoek 9990 is " & mvrGbOmschrijving
'Journaalpost openen
.mtdGWayJpAanmaken Now, 9990, "ABC", "OmschrijvingXYZ"
'Regels aan JournaalPost toevoegen
.mtdGWayJpRegelToevoegenV616 8001, "DebetZZZZ", 100, 0
.mtdGWayJpRegelToevoegenV616 8002, "CreditYYYY", 0, 75
.mtdGWayJpRegelToevoegenV616 8002, "CreditYYYY", 0, 25
'Journaalpost sluiten
.mtdGWayJpSluiten
'Starten applicatie
End With
Exit Sub
ErrorHandler:
mtdMsg mtdGWayFoutBoodschap("mtdToevoegenJournaalPost"), vbInformation
End Sub

Private Sub mtdWijzigenJournaalPost()
On Error GoTo ErrorHandler
'Declaratie variabelen
Dim mvrGWaySnelStart As clsGWaySnelStart
Dim mvrGWayJournaalPost As clsGWayJournaalPost
Dim mvrGWayJournaalRegel As clsGWayJournaalRegel
'Aanmaken nieuwe ToegangsObject
Set mvrGWaySnelStart = New clsGWaySnelStart
With mvrGWaySnelStart

'-----------------------------------------------------
'Voorbeeld 1 met verwijderen van een journaalpostregel
'-----------------------------------------------------
Set mvrGWayJournaalPost = .mtdGWayJournaalPostGet(502)
'Wijzig het GrootboekNummer op vierde journaalpostregel
mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(4).prpGWayGrootboekNummerSet = 3006
'Voeg 4e en 5e journaalpostregel samen
mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(4).prpGWayDebetSet = mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(4).prpGWayDebetGet + _
mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(5).prpGWayDebetGet
mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(4).prpGWayCreditSet = mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(4).prpGWayCreditGet + _
mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(5).prpGWayCreditGet
'Verwijder de 5e journaalpostregel
mvrGWayJournaalPost.mtdJpRegelRemove 5
'Voer wijziging door
.mtdGWayJpWijzigen mvrGWayJournaalPost

'---------------------------------------------------
'Voorbeeld 2 met toevoegen van een journaalpostregel
'---------------------------------------------------
Set mvrGWayJournaalPost = .mtdGWayJournaalPostGet(503)
'Wijzig totaalbedrag
mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(1).prpGWayDebetSet = mvrGWayJournaalPost.mtdGetJournaalRegelOpIndex(1).prpGWayDebetGet + 100
'Voeg extra regel toe
'Vul de nieuwe regel
mvrGWayJournaalRegel.prpGWayDebetSet = 0
mvrGWayJournaalRegel.prpGWayCreditSet = 100
mvrGWayJournaalRegel.prpGWayBtwIDSet = encGWayBtwIDGeen
mvrGWayJournaalRegel.prpGWayBtwPercentageSet = 0
mvrGWayJournaalRegel.prpGWayBtwTypeSet = encGWayBtwTypeNvt
mvrGWayJournaalRegel.prpGWayFactuurNummerSet = "20050918"
mvrGWayJournaalRegel.prpGWayFactuurRelatiecodeSet = 2
mvrGWayJournaalRegel.prpGWayGrootboekNummerSet = 8095
mvrGWayJournaalRegel.prpGWayOmschrijvingSet = "extra regel"
'Voer wijziging door
.mtdGWayJpWijzigen mvrGWayJournaalPost

'Starten applicatie
End With
Exit Sub
ErrorHandler:
mtdMsg mtdGWayFoutBoodschap("mtdWijzigenJournaalPost"), vbInformation
End Sub

Private Sub mtdInkoopOrderToevoegen()
On Error GoTo ErrorHandler
'Declaratie variabelen
Dim mvrGWaySnelStart As clsGWaySnelStart
Dim mvrGWayJournaalPost As clsGWayJournaalPost
Dim mvrGWayJournaalRegel As clsGWayJournaalRegel
'Aanmaken nieuwe ToegangsObject
Set mvrGWaySnelStart = New clsGWaySnelStart
With mvrGWaySnelStart

'Inkooporder aanmaken
.mtdGWayInkoopOrderAanmaken 1, 30123, Now, "Inkoop via gateway", "memo-tekst", "bk inkoop"
'Regels toevoegen
.mtdGWayInkoopOrderRegelToevoegenArtikelMetDefaults 12, 100
.mtdGWayInkoopOrderRegelToevoegenArtikel 12, "Eigen omschrijving", 50, 1.12, 10, 1
.mtdGWayInkoopOrderRegelToevoegenTekst "Echte tekstregel", 0, 0
.mtdGWayInkoopOrderRegelToevoegenTekst "Tekstregel met bedrag en kostenplaats", 10, 2
'Voer wijziging door
.mtdGWayInkoopOrderSluiten

'Starten applicatie
End With
Exit Sub
ErrorHandler:
mtdMsg mtdGWayFoutBoodschap("mtdWijzigenJournaalPost"), vbInformation
End Sub

Private Sub mtdVerkoopAbonnementOrderToevoegen()
On Error GoTo ErrorHandler
'Declaratie variabelen
Dim mvrGWaySnelStart As clsGWaySnelStart

Dim mvrSjabloonID As Long
Dim mvrRelatieCode As Long
Dim mvrDatum As Date
Dim mvrOmschrijving As String
Dim mvrOrderMemo As String
Dim mvrKostenplaatsenNummer As Long
Dim mvrBetalingsKenmerk As String

Dim mvrAbonnementIntervalSoort As enmGWayAbonnementInterval
Dim mvrAbonnementIntervalAantal As Variant
Dim mvrAbonnementTijdstipMaand As Variant
Dim mvrAbonnementTijdstipWeekDag As Variant
Dim mvrAbonnementTijdstipMaandDag As Variant
Dim mvrAbonnementTijdstipWeekVanMaandDag As Variant
Dim mvrAbonnementBegindatum As Variant
Dim mvrAbonnementEindDatum As Variant
Dim mvrAbonnementEindeNaAantal As Variant

'Aanmaken nieuwe ToegangsObject
Set mvrGWaySnelStart = New clsGWaySnelStart
With mvrGWaySnelStart

'Verkooporder aanmaken
mvrSjabloonID = 1
mvrRelatieCode = 10001
mvrDatum = Now
mvrOrderMemo = "memo"
mvrKostenplaatsenNummer = 0
mvrBetalingsKenmerk = "BK"

Also, please post the code you tried, and any errors you might have encountered.

I have tried some codes, none worked (they are probably very noobish because I have never used them before).

Codes i tried:

$dll = DllOpen($dllPath)

If $dll = -1 Then _Err("Kon SnelStartGateWay.dll niet openen!") EndIf$result = DllCall($dll, "none", "_clsGWaySnelStart::mtdGWayAdmiOpenen"); also tried "DllGetClassObject" as function, this made AutoIt time-out/crash after a while$error = @error

If $error Then _Err("DLLCall #1 Error: " &$error)
EndIf

_Msg("DLLCall #1 Result: " & $result) DllClose($dll)

$obj = ObjCreate("SnelStartGateWay.application")$error = @error

If $error Then _Msg("SnelStart Sync maakt een poging om SnelStartGateWay.dll te registreren." & @LF & "Druk op OK.") Break(0) RunWait('regsvr32 "' &$dllPath & '"')
$obj = ObjCreate("SnelStartGateWay.application")$error = @error

If $error Then Run('regsvr32 /u "' &$dllPath & '"')
EndIf

Break(1)

If $error Then _Err("ObjCreate #1 Error: " &$error)
EndIf
EndIf

$dll = _WinAPI_LoadLibrary($dllPath)

If $dll Then ; ... (didn't know what i would have to do here :P) _WinAPI_FreeLibrary($dll)
Else
_Err("Kon SnelStartGateWay.dll niet openen!"); it did not give this error message tho XD
EndIf
MsgBox(0x40040, "", "Hello Forum!")
Share on other sites

Does the VB6 code work? If not then the dll is likely not registered on the system. Search the registry for the string you use in ObjCreate() function. If that string is not found then it's not registered. Try regsvr32 or one of those shell extensions that registers and unregisters COM libraries.

edit: also if it's a licensed ActiveX Control designed to drop on a form such as in VB6, it won't work without the .lic file. It would need a design time license before it would instantiate on the form(the .lic file.) A program using it will run but you can't use it in a form designer without the license if it's a licensed control.

First thing I'd do is try to get the VB6 example to go. If it doesn't you're likely wasting your time.

Share on other sites

Hi 1RV34,

Now that's a greatly informative post!

I don't understand a word of dutch however , but with Google Translate I managed to cobble up a couple lines to get you started,

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler$oSnel = ObjCreate("SnelStartGateWay.clsGWaySnelStart")
If IsObj($oSnel) Then MsgBox(64, "", "Object created successfully") EndIf MsgBox(64, "Version",$oSnel.prpGWayVersieGateWayGet())

$oSnel2 = ObjCreate("SnelStartGateWay.clsGWArtikel") If IsObj($oSnel2) Then
MsgBox(64, "", "Object created successfully")
EndIf

; This is the custom error handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
"Number is: " & $HexNumber & @CRLF & _ "Windescription is: " &$oMyError.windescription & @CRLF & _
"Source is: " & $oMyError.source & @CRLF & _ "Description is: " &$oMyError.description & @CRLF & _
"Helpfile is: " & $oMyError.helpfile & @CRLF & _ "Helpcontext is: " &$oMyError.helpcontext & @CRLF & _
"Lastdllerror is: " & $oMyError.lastdllerror & @CRLF & _ "Scriptline is: " &$oMyError.scriptline)
EndFunc   ;==>MyErrFunc

Hope this little tidbit helps

-smartee

Edit: some spelling, greets

Edited by smartee

Yes

$oSnel = ObjCreate("SnelStartGateWay.clsGWaySnelStart") Just that line helped a lot already! I didn't know which function I needed (DllCall, ObjCreate or _WinAPI_LoadLibrary) and also if I needed ObjCreate I didn't know I needed "SnelStartGateWay.clsGWaySnelStart" I tried stuff like "SnelStartGateWay.application" XD (never used it before o.o) Thanks for this example & making me understand ObjCreate more! MsgBox(0x40040, "", "Hello Forum!") Link to post Share on other sites The name of the automation used for IDispatch is always in the registry somewhere as a clsid. For instance if you have Scripting Dictionary installed you'll see "Scripting.Dictionary" defined somewhere. Usually things that support IDispatch have type library information. Languages like C++ often you can import the type library and the Intellisense will automatically pick up the methods once you create an instance. A lot of program code is in English when the language of origin is not just because so many compilers etc.. were created in English. 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 • Recently Browsing 0 members No registered users viewing this page. • Similar Content • Hi all, My programming knowledge is very basic. I have an old script that creates shares and assign permissions. It normally registers SetAcl.ocx if necessary and creates an object to assign permissions. The command that registers SetAcl was apparently working fine under Windows 7 but is not working under Windows 10. RunWait("regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE) As I'm logged in as admin, I changed this command to : RunAsWait(@UserName, "", "", 0, "regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE) It seems to terminate correctly but the script still doesn't work as expected. To check that, I've created that small script : Local$objSetAcl = ObjCreate("SETACL.SetACLCtrl.1") If IsObj($objSetAcl) Then ConsoleWrite("Object successfully created." & @CRLF) Else ConsoleWrite("Object not created. Registering SetAcl.ocx" & @CRLF) Local$result = RunAsWait(@UserName, "", "", 0, "regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE); Use of my admin username to elevate CMD ConsoleWrite("Return code : " & $result & @CRLF) ConsoleWrite("Creating object" & @CRLF)$objSetAcl = ObjCreate("SETACL.SetACLCtrl.1") If IsObj(\$objSetAcl) Then ConsoleWrite("Object successfully created." & @CRLF) Else ConsoleWrite("Object creation failed." & @CRLF) EndIf EndIf It tries to register SetAcl.ocx, return code 0 seems to be fine but still can't use SetAcl.
But if I go to CMD as admin, run the regsvr32 command and restart my script, it can create the object without issue.
I know my poor knowledge makes me miss something. Anyone can help me figure this out ?

• Dear members of the forum,
I'm working on a project in which I have to use Image recognition technique.
Due to client restrictions, I couldn't use AutoIt for this project.
Is there a way to use this DLL "ImageSearchDLL.dll" (which is used to do image recognition steps in AutoIt) in VB.Net to achieve the same result?
I have used this DLL few years before and got good results. If there is a latest version of this DLL and if you can share it, that will be helpful too.
Any guidance is deeply appreciated.

• Hi AutoIt Scripters/Programmers. I have a question about MIME Tools for Notepad++:
I've recently found a UDF about Base64 in forum, but they can't decode\encode correctly some emojis , other UTFs and etc. so i decided to use mimeTools.dll of Notepad++ or main site
My problem is how to use this dll in AutoIt Language?

• Good morning Forums
In these days, I am working on a project that involved me to use some Windows APIs to obtain some information about Terminal Servers.
I'm doing this using wtsapi32.dll in a VBA Project, but, the lack of knowledge about few things threated in the articles make this quite difficult to
implement and understand at the same time.
The most difficult thing I'm facing is "translating" C/C++ functions or struct in VBA when pointers are used, or pointers of pointers, and so on.
Since VBA seems to not have a pointer type, to make those functions work I need to implement other functions taken from other DLLs, and this confuses me a lot.
For example, starting from this code, I splitted all the functions and all the definitions to understand why they are there, and why I need to use them.
At the end, I've found out that the code I was going to implement starting from the functions provided in the Microsoft Docs won't be ever be able to work without some supplementary functions which are not mentioned anywhere.
So, I was wondering if someone would please point me out to a good and practical exaplanation about pointers (in general) or specifically for VBA, because I need to use them quite often in these days, and I'd like to understand what I am doing.