Jump to content



Photo

Calls to "_class::property" stuff

com dll dllcall objget

  • Please log in to reply
8 replies to this topic

#1 1RV34

1RV34

    Seeker

  • Active Members
  • 43 posts

Posted 13 February 2012 - 07:50 AM

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, 13 February 2012 - 12:35 PM.

MsgBox(0x40040, "", "Hello Forum!")







#2 1RV34

1RV34

    Seeker

  • Active Members
  • 43 posts

Posted 21 February 2012 - 01:29 PM

Some aditional information:
Using a DLL viewer I saw these functions:
  • DllCanUnloadNow
  • 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!")

#3 smartee

smartee

    Hippies.They're everywhere.

  • Active Members
  • PipPipPipPipPipPip
  • 653 posts

Posted 22 February 2012 - 09:32 PM

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.

Help us help you :)
-smartee

#4 MilesAhead

MilesAhead

    Eclectician

  • Active Members
  • PipPipPipPipPipPip
  • 531 posts

Posted 22 February 2012 - 09:45 PM

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.

Edited by MilesAhead, 22 February 2012 - 09:47 PM.

"I don't want to belong to any club that would have me as a member."- Groucho Marx

#5 1RV34

1RV34

    Seeker

  • Active Members
  • 43 posts

Posted 23 February 2012 - 12:02 PM

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.

Plain Text         
Private Sub mtdToevoegenJournaalPost()   On Error GoTo ErrorHandler   'Declaratie variabelen   Dim mvrGWaySnelStart As clsGWaySnelStart   Dim mvrAdmiInEuro As Boolean   Dim mvrGbOmschrijving As String   'Aanmaken nieuwe ToegangsObject   Set mvrGWaySnelStart = New clsGWaySnelStart   With mvrGWaySnelStart     'Openen administratie     .mtdGWayAdmiOpenen "C:SnelStartAdministraties", "SnelStart Voorbeeldbedrijf"     'Uitlezen of Administratie in Euro's is     mvrAdmiInEuro = .prpGWayAdmiInEuroGet     Debug.Print "Adminitratie in Euro is " & mvrAdmiInEuro     '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     'Sluiten administratie     .mtdGWayAdmiSluiten     'Starten applicatie     .mtdGWayRunSnelStart "C:SnelStartAdministratiesSnelStart Voorbeeldbedrijf"   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     'Openen administratie     .mtdGWayAdmiOpenen "C:SnelStartAdministraties", "SnelStart Voorbeeldbedrijf"     '-----------------------------------------------------     '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     Set mvrGWayJournaalRegel = mvrGWayJournaalPost.mtdJpRegelAdd     '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     'Sluiten administratie     .mtdGWayAdmiSluiten     'Starten applicatie     .mtdGWayRunSnelStart "C:SnelStartAdministratiesSnelStart Voorbeeldbedrijf"   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     'Openen administratie     .mtdGWayAdmiOpenen "C:SnelStartAdministraties", "SnelStart Voorbeeldbedrijf"     '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     'Sluiten administratie     .mtdGWayAdmiSluiten     'Starten applicatie     .mtdGWayRunSnelStart "C:SnelStartAdministratiesSnelStart Voorbeeldbedrijf"   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 mvrVerkoperLoginNaam 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     'Openen administratie     .mtdGWayAdmiOpenen "C:SnelStartAdministraties", "SnelStart Voorbeeldbedrijf"     '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!")

#6 MilesAhead

MilesAhead

    Eclectician

  • Active Members
  • PipPipPipPipPipPip
  • 531 posts

Posted 23 February 2012 - 10:16 PM

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.

Edited by MilesAhead, 23 February 2012 - 10:23 PM.

"I don't want to belong to any club that would have me as a member."- Groucho Marx

#7 smartee

smartee

    Hippies.They're everywhere.

  • Active Members
  • PipPipPipPipPipPip
  • 653 posts

Posted 24 February 2012 - 03:13 AM

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,
AutoIt         
$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, 24 February 2012 - 03:16 AM.


#8 1RV34

1RV34

    Seeker

  • Active Members
  • 43 posts

Posted 27 February 2012 - 09:37 AM

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! :oops:
MsgBox(0x40040, "", "Hello Forum!")

#9 MilesAhead

MilesAhead

    Eclectician

  • Active Members
  • PipPipPipPipPipPip
  • 531 posts

Posted 28 February 2012 - 02:00 AM

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.
"I don't want to belong to any club that would have me as a member."- Groucho Marx





Also tagged with one or more of these keywords: com, dll, dllcall, objget

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users