Results 1 to 16 of 16

Thread: ImageSearchDLL Not working with VB6.0

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2014
    Posts
    3

    Unhappy ImageSearchDLL Not working with VB6.0

    Hello,
    can somebody help me with ImageSearchDLL to make it work ?
    Here is my code :

    Code:
    Private Declare Function ImageSearch Lib "C:\Users\DragosPc\Desktop\sss\ImageSearchDLL.dll" _
    (ByVal x1 As Integer, ByVal y1 As Integer, ByVal right As Integer, ByVal bottom As Integer, ByVal findImage As String) As String
    
    Private Sub Command1_Click()
    
    Dim result As String
    
    result = ImageSearch(0, 0, 0, 0, "C:\test.bmp")
    
    Debug.Print result
    
    
    End Sub
    And the Debug.Print returns a strange output:
    0 1|%d|%d|%d|%d à?E´ ä³ ä³ e+000 À~PA €ÿÿGAIsProcessorFeaturePresent KERNEL32 1#QNAN 1#INF 1#IND 1#SNAN H P RSDS!›Î1äÉ÷D‡D4Š*/^ c:\imagesearchdll\release\ImageSearchDLL.pdb `D X} ¥ þÿÿÿ Ôÿÿÿ þÿÿÿ Û% ...
    i search and found this thread but didn't help me
    http://www.vbforums.com/showthread.p...ht=imagesearch

    You can download the dll from here : http://spacefighters.rr.nu/download/ImageSearchDLL.dll


    Any ideea ?
    Last edited by dimandragos; Nov 20th, 2014 at 11:11 AM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ImageSearchDLL Not working with VB6.0

    You need to remove that DLL from you zip file. If you have a link where someone can download the DLL, then provide that instead. The rules of this forum are that you cannot upload executable files
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2014
    Posts
    3

    Re: ImageSearchDLL Not working with VB6.0

    Quote Originally Posted by LaVolpe View Post
    You need to remove that DLL from you zip file. If you have a link where someone can download the DLL, then provide that instead. The rules of this forum are that you cannot upload executable files
    Done, Thanks !

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ImageSearchDLL Not working with VB6.0

    Do you know if that DLL is using a stdCall or cDecl calling convention. It really matters. If you don't know, you need to try to find out. It appears your return string is corrupted & personally, leaning towards cDecl. From what I can find on the net, the return string should be no more than 50 characters. The source code for that DLL would be helpful
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ImageSearchDLL Not working with VB6.0

    Here's an idea easy enough to test. Change all 4 Integer types to Long within the function declaration. Unless the DLL is written for 16 bit O/S, likely meant to be Longs.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: ImageSearchDLL Not working with VB6.0

    Wow LaVolpe, do you think VB6 can make a call that uses the cDecl convention? Gosh, I wouldn't even begin to know how to manually change the stack pointer from within VB6, which would be required upon return of a call using the cDecl convention. I actually Googled just a bit and apparently there are some C "interface" DLLs but wow, what a pita.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ImageSearchDLL Not working with VB6.0

    Quote Originally Posted by Elroy View Post
    Wow LaVolpe, do you think VB6 can make a call that uses the cDecl convention? Gosh, I wouldn't even begin to know how to manually change the stack pointer from within VB6, which would be required upon return of a call using the cDecl convention. I actually Googled just a bit and apparently there are some C "interface" DLLs but wow, what a pita.
    Yes, Paul Caton created a thunk and I've used it quite a bit for ZLIB (CDecl) calls. If interested, you can find it on PSC, search for Paul Caton Universal DLL
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: ImageSearchDLL Not working with VB6.0

    You know, PSC has been down for the last day or two. I sure hope that's not a permanent state of affairs.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: ImageSearchDLL Not working with VB6.0

    Quote Originally Posted by LaVolpe View Post
    Yes, Paul Caton created a thunk and I've used it quite a bit for ZLIB (CDecl) calls. If interested, you can find it on PSC, search for Paul Caton Universal DLL
    The (oleaut32.dll) DispCallFunc-API supports all kinds of different calling-conventions,
    __cdecl among them, as well as COM-calls using simple VTable-Offsets, to be able to
    work against COM-interfaces which are not easily reachable per VB (having no IDispatch,
    or no Typelib available anywhere).

    The example below includes a __cdecl-Demo against wsprintf in the C-runtime (msvcrt.dll) -
    as well as a Demo, how to implement a simple COM-Interface using this technique (ITaskBarList3).

    Here's the Demo: DispInvokeDemo.zip

    Olaf

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ImageSearchDLL Not working with VB6.0

    Quote Originally Posted by Schmidt View Post
    The (oleaut32.dll) DispCallFunc-API supports all kinds of different calling-conventions,
    __cdecl among them, as well as COM-calls using simple VTable-Offsets, to be able to
    work against COM-interfaces which are not easily reachable per VB (having no IDispatch,
    or no Typelib available anywhere).

    The example below includes a __cdecl-Demo against wsprintf in the C-runtime (msvcrt.dll) -
    as well as a Demo, how to implement a simple COM-Interface using this technique (ITaskBarList3).

    Here's the Demo: DispInvokeDemo.zip

    Olaf
    I'm aware of that & have used it or COM objects. Don't believe the dll in question is ActiveX. FYI: Paul Caton's thunk addressed standard DLLs
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #11
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: ImageSearchDLL Not working with VB6.0

    Quote Originally Posted by LaVolpe View Post
    I'm aware of that & have used it or COM objects.
    Don't believe the dll in question is ActiveX.
    FYI: Paul Caton's thunk addressed standard DLLs
    You missed my point entirely (perhaps didn't even looked at the demo),
    since it demonstrated calls against msvcrt.dll, which *is* a __cdecl-exporting Standard-Dll...

    So the DispCallFunc-API supports not only Calls per VTable-Pointer-offsets into COM-Instances,
    but also Func-Pointer-Calls against "Flat-Dlls" (__stdcall convention as well as __cdecl convention).

    Olaf

  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ImageSearchDLL Not working with VB6.0

    That's pretty cool. Where did you find the documentation on that function? When I last researched that API, everything I found indicated it was intended/used only for IDispatch::Invoke.

    Had no idea you could pass the function pointer as the VTable parameter along with a null pUnk and it would happily call the function.

    FYI: For another sample usage of that API with call made to a VB object (drag/drop DataObject), this posting shows one way of extracting dropped files from a Windows compressed folder
    Last edited by LaVolpe; Nov 21st, 2014 at 08:16 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13

    Thread Starter
    New Member
    Join Date
    Nov 2014
    Posts
    3

    Thumbs up Re: ImageSearchDLL Not working with VB6.0

    Vb .Net
    Code:
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        <DllImport("ImageSearchDLL.dll", EntryPoint:="ImageSearch")> _
        Public Shared Function ImageSearch(ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal str As String) As String
        End Function
    
        Public Shared Function FindImage(ByVal bmp As String) As Integer()
            Dim x1 As Integer
            Dim y1 As Integer
    
            Dim Array1 As Integer() = New Integer(2) {}
            Dim strRes As String = ImageSearch(x1, y1, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, bmp)
            If strRes = "0" Then
                Array1(0) = 0
                Return Array1
            Else
                Dim co As String() = strRes.Split("|"c)
                Array1(0) = Integer.Parse(co(1))
                Array1(1) = Integer.Parse(co(2))
                Return Array1
            End If
        End Function
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            
            Dim Res() As Integer = FindImage("C:\test.bmp")
    
            If Res(0) > 0 And Res(1) > 0 Then
                MessageBox.Show("The position of the image is :" & vbNewLine & _
                    "Width: " & Res(0).ToString() & vbNewLine & _
                    "Height: " & Res(1).ToString())
            Else
                MessageBox.Show("Can't find image on screen !")
            End If
    
        End Sub
    
    End Class
    Back, i think i will finish my project in Vb .Net but if somebody can fix that code(vb6) i will be grateful.

    Thank you for all your help.

    LaVolpe, i like your projects on psc
    Last edited by dimandragos; Nov 21st, 2014 at 07:39 AM.

  14. #14
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: ImageSearchDLL Not working with VB6.0

    Quote Originally Posted by LaVolpe View Post
    Where did you find the documentation on that function? When I last researched that API, everything I found indicated it was intended/used only for IDispatch::Invoke.

    Had no idea you could pass the function pointer as the VTable parameter along with a null pUnk and it would happily call the function.
    You're right, the MSDN-documentation doesn't point out this behaviour or "mode" -
    not sure where I read this first (a few years ago) - I think it was in a german forum...

    Olaf

  15. #15
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: ImageSearchDLL Not working with VB6.0

    Quote Originally Posted by Schmidt View Post
    ... not sure where I read this first (a few years ago) - I think it was in a german forum...
    Quote Originally Posted by Schmidt View Post
    @Zvoni
    The DispCallFunc is basically the "generic and official Function-Caller by pointer", every VB-Dev was
    always looking for (often resorting to CallWindowProc- or ASM-Hacks instead) - not sure who needs
    to be given the credits for the first working VB-example (wasn't me, found it not that long ago
    in a german forum the first time)... googling - ... - well, seems that the first "working VB-example"
    is from 2003: http://www.activevb.de/tipps/vb6tipps/tipp0600.html



    I was using Paul Catons stuff before - but since there was this nice explicit Parameter CC_STDCALL
    I googled a bit more and found a whole Enum-List:

    Public Enum CallingConventions
    CC_FASTCALL
    CC_CDECL
    CC_PASCAL
    CC_MACPASCAL
    CC_STDCALL
    CC_RESERVED
    CC_SYSCALL
    CC_MPWCDECL
    CC_MPWPASCAL
    End Enum

    More googling and experimenting revealed, that the Function-Pointer is internally resolved by:
    dereferencedResultOfParam_ppv + Vtbl_Offset

    And (luckily) passing a Null to ppV - and the direct Function-Pointer in the Vtbl-Offset-Param,
    one can do also all kind of "normal API-Calls" (not only Disp- or COM-Calls).
    And in this "direct FuncPtr-Mode", the above Enum comes in very handy - and is working as
    expected.

    Here's a small Demo, which shows all 3 "Modes", in which DispCallFunc can be used now with
    VB (StdCall-, CDECL- calls and of course also COM- (VTbl-) Calls.

    http://www.vbRichClient.com/Download...InvokeDemo.zip

    Olaf
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  16. #16
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: ImageSearchDLL Not working with VB6.0

    Thanks Bonnie, for digging that out.
    (was aware that I've posted the info somewhere recently, but not that it was here in this Forum) ...

    The blessings of getting old(er) perhaps.

    Olaf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width