Results 1 to 9 of 9

Thread: Bad DLL calling convention ???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Question

    I am trying to use the icq api but am getting this error message when I try to use one of the function.

    The function set wich of MY functions (In my app) will be called when a certain notification from ICQ arrives...

    here goes..
    Now the documentation for the ICQ API is written for C++, I have managed to convert most of them but maybe this one is not converted correctly ?

    What the documentation says:
    Code:
    void WINAPI ICQAPIUtil_SetUserNotificationFunc(UINT uNotificationCode, void *pUserFunc);
    In a module:
    Code:
    Public Declare Function ICQSetUserNotificationFunc Lib "ICQMAPI.dll" Alias "ICQAPIUtil_SetUserNotificationFunc" (uNotificationCode As Integer, ByVal pUserFunc As Variant)

    In the code of a form:
    Code:
    Call ICQSetUserNotificationFunc(1, AddressOf ICQOnlineListChange)
    Is the function converted correctly ? if it is, what is the problem. If not , How should it be?

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Try

    Code:
    Public Declare Function ICQSetUserNotificationFunc Lib "ICQMAPI.dll" Alias "ICQAPIUtil_SetUserNotificationFunc" (uNotificationCode As Long, ByVal pUserFunc As Long)


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241
    Thanks for the reply...

    I have tried your declaration but still get the same error message...

    Any other ideas?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241
    I just read about "_stdcall" for use with AdressOf...
    Should I use this?
    What is it?
    How do I use it?

  5. #5
    Member
    Join Date
    Feb 2000
    Posts
    52
    Originally posted by David Laplante
    I just read about "_stdcall" for use with AdressOf...
    Should I use this?
    What is it?
    How do I use it?

    In C++, you specify this as part of the function type
    declaration to tell the compiler how the addressing is
    handled. I've only had call to use this in a C++ DLL, so
    don't know how it applies in VB.

    [Edited by ShepherdOfChaos on 05-06-2000 at 12:08 AM]

  6. #6
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    The 2nd is Definatley a function pointer, which means you need to declare it as a long and use the addressof operator

    The First is a UINT which sounds like an unsigned integer but it could be a long one or a short one, so if the 2 longs don't work then try an integer and a long.


    Actually I've just noticed it's a function so It returns something, which the C++ code doesn't try declaring it as a sub

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Thumbs up

    YEAH BABY!

    That worked! of course! how could I have not seen it... it was declared a VOID... wich means it doesn't return anything. It was a SUB not a FUNCTION

    Thanks for your help!

  8. #8
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    that's just one of those annoying things that nobody spots, I once spent 2 monts trying to debug a subclassing procedure only to realise that I'd forgotten to declare my parameters ByVal. D'OH

  9. #9
    Lively Member Ceri's Avatar
    Join Date
    Sep 2000
    Posts
    72
    Sometimes you can define a DLL function correct and then VB still tells you that it's not,

    If you put an On Error Resume Next just before the DLL and an On Error Goto 0 just after the DLL, you will probably find that the function did execute allthough VB tell's you it didn't

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