Announcement

Collapse
No announcement yet.

Bug or Feature?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tom Hanlin
    replied
    Where the "multiple declarations sharing a single alias" would be most useful is when you have a WinAPI function which accepts a variable number of parameters.
    Optional parameters are already supported. See the Win32API.inc declare for wsprintf.


    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Fred Oxenby
    replied
    Why not use "loadlibrary" and define functions the way "You" want them?


    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Leave a comment:


  • Eric Pearson
    replied
    A UNION would also be an easy way to do this. Create a UNION with all of the different ways you want to pass values to the API, then change the API declaration to accept a TYPE that contains the UNION.

    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited October 22, 2001).]

    Leave a comment:


  • Borje Hagsten
    replied
    Can also do own ZeroMemory, like:
    Code:
      POKE$ lpDest, STRING$(numBytes, 0)
    Otherwise, maybe possible to place second declare in a separate DLL?


    ------------------

    Leave a comment:


  • Michael Mattias
    replied
    can't you use an #ifdef type idea or do you need to use them both together?
    Where the "multiple declarations sharing a single alias" would be most useful is when you have a WinAPI function which accepts a variable number of parameters.

    Code:
    DECLARE Function FooWithOne Lib "WHATEVER" ALIAS "WinApiFunc" (parm1) AS LONG
    DECLARE FUNCTION FooWithTwo Lib "WHATEVER" ALIAS "WinApiFunc" (parm1, Parm2) AS LONG
    
    
       CALL FooWithOne (X)
       CALL FooWithTwo (X,Y)
    I forget off the top of my head which functions work like this, but I know there are some. (Wsprintf?)

    Also useful for overriding a datatype..

    Code:
    DECLARE FUNCTION FooLong  Lib "whatever" ALIAS "Foo" (X AS LONG) AS LONG
    DECLARE FUNCTION FooDword Lib "whatever" ALIAS "Foo" (X AS DWORD) AS LONG
    
      Z = FooLong (2&)
      ZZ = FooDword (2???)
    As long as the target routine is only looking for "32-bit anything" either version should work.


    MCM

    Leave a comment:


  • Wayne Diamond
    replied
    One workaround - change the second declare of "RtlMoveMemory" to something like "RtlMoveMemor2". Compile, use a hex editor, and rename it back.
    It seems to work fine when I just tested it with Beep(), but I'm not sure if there are any negative implications in doing this.

    Best of luck,
    Wayne


    [This message has been edited by Wayne Diamond (edited October 22, 2001).]

    Leave a comment:


  • Paul Dwyer
    replied
    can't you use an #ifdef type idea or do you need to use them both together?




    ------------------
    Paul Dwyer
    Network Engineer
    Aussie in Tokyo

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Hmmmmmmmm, PB with overloaded function capability? Sounds like
    an outstanding idea.

    Cheers,
    Cecil

    ------------------

    Leave a comment:


  • Michael Mattias
    replied
    To answer the question, "Bug or Feature?":

    I think it's a "negative feature."

    A negative feature is something which "works as designed" but the design itself is of dubious worth.

    Kinda like Microsoft "Bob."

    MCM
    (And by the way, allowing multiple declarations of same-aliased external functions would be a terrific new feature.)

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Download the latest win32 API file. It contains Movememory wrapped into a CopyMemory function. Currently, you can't declare the same API function name (in quotes after alias more than once so a work-around is necessary.

    Leave a comment:


  • Torsten Rienow
    started a topic Bug or Feature?

    Bug or Feature?

    Hi,

    i need to have declare several versions of an api
    function/sub like this.
    PB will not compile, and returns error 466.
    Is there any workaround?


    #COMPILE EXE

    DECLARE FUNCTION MoveMemory LIB "KERNEL32.DLL" ALIAS "RtlMoveMemory" (lpDest AS ANY, lpSource AS ANY, BYVAL cbMove AS LONG) AS LONG
    DECLARE SUB ZeroMemory LIB "KERNEL32" ALIAS "RtlMoveMemory" (BYVAL lpDest AS LONG, BYVAL numBytes AS LONG)

    FUNCTION PBMAIN

    END FUNCTION


    ------------------
Working...
X