Announcement

Collapse
No announcement yet.

Call Dword, returns odd string/asciiz values?

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

  • Call Dword, returns odd string/asciiz values?

    Heya,
    Thanks in Advance..

    I'm using the call Dword statement, I know it's successfully calling the function from the .dll, and i'm using the "USING' statement along with it. BUT, It doesn't return a string value. When I use a string value for instance and say

    Call Dword blahblah using blahblah(blah,blah,blah) to stringVar

    It retruns a string that's like 78768 bytes long, when i'm only returning a string of 5 characters. And when i change the .dll and the declares in the .exe to use the Asciiz * 50 type dec instead of String, it doesn't return anything, and the length of the data is 0. I'm stuck, this function works fine with Byte, Long, etc... Help.

    Function pInit Alias "pInit" (pMode As Byte, sckPtr As Dword, cfgPtr As Dword) Export As Asciiz * 64

    <CODE>
    Code:
    (sLibName = String Array, or Asciiz Array)
    (Dword must be used so please don't specify a solution of using implicit .dll calling. thanks)
    
    ReDim Preserve sLibName(1 [img]http://www.powerbasic.com/support/forums/tongue.gif[/img]lgCount)
    idPlugin(plgCount) = LoadLibrary(outFile)
    pAddr = GetProcAddress(idPlugin(plgCount), "pInit")
    Call Dword pAddr Using _
         pInit(%SERVER, CodePtr(sckSend), CodePtr(GetConfig)) _
              To sLibName(plgCount)
    ------------------

  • #2
    STRING and ASCIIZ * 50 are two quite different types. The pInit function
    you show uses ASCIIZ * 64, yet another type...? If you could show us
    exactly what you're aiming to do, it will be easier to offer useful advice.


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

    Comment


    • #3
      Woops, let me attempt to reiterate this a bit differently..

      What i want to do:
      Have an application explicitly call a function, and have that functions return a string value. This needs to be done using the Call Dword statement. In doing this I've experienced problems, specifically ridiculously large strings are being returned, or depending on what type I use (whether i use an asciiz, string *, or normal string type, the outcome differs, but it is always extremely incorrect). I simply want the called .dll function to pass it's returned string value successfully to a string value inside the executeable.

      Note:
      I'm using the "USING" statement, and the function I declare in the app precisely matches the function I'm calling in the .dll, so everything mathces up, types, param list, etc. It just isn't returning the string.

      Note 2:
      HELPPPP!!!!! Thank you.


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

      Comment


      • #4
        Looks like there's a problem with using array elements in the TO clause.
        Try using a simple string variable there instead.

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

        Comment


        • #5
          Heya,

          Well it still seems to return absolutely nothing, a len of 0, when I use a standard string variable instead of an array. Has anyone else had trouble returning string values with the Call Dword/Using/To clause. Longs, integers, bytes, seem to work fine. Strings, Asciiz, etc, it returns nothing, or something over 78k if I use these datatypes as arrays. Help!~

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

          Comment


          • #6
            Please repost the EXACT code you are trying to get going here... thanks!


            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              MY appologies, it works fine, the only time an error is triggered, or invalid data/corruption is passed, is when you're using the TO statement with a string array, as has been pointed out by Mr. Hanlin, I'm hoping future versions of PowerBasic will allow the support for using Call Dword, and the To operator to return string variables to a string array, instead of just a single string. Thanks again.!

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

              Comment


              • #8
                Great. Yes, the suggestion has already been put forward to R&D.

                Thanks!

                ------------------
                Lance
                PowerBASIC Support
                mailto:[email protected][email protected]</A>
                Lance
                mailto:[email protected]

                Comment

                Working...
                X