Announcement

Collapse
No announcement yet.

C Declaration Conversion

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

  • C Declaration Conversion

    Code:
    C Declaration
    --------------
    char* _stdcall GMW_NewRecID( char *pBuff, char *pUser );
    
    
    VB Declaration
    --------------
    Public Declare Function GMW_NewRecID Lib "GM6S32.dll" (Byval szRecid As string, _
                                                           ByVal szUser As String) As string
    
    
    PB Declaration
    --------------
    DECLARE FUNCTION GMW_NewRecID LIB "GM6S32.dll" (BYREF zRecId AS ASCIIZ, _
                                                    BYREF zUser AS ASCIIZ) AS LONG

    Hi All!

    I'm trying to convert a C declaration to PB. I think I've got it right, but it doesn't appear to be working. Each time I call the following code, I get an error message that says "The procedure entry point GMW_NEWRECID could not be located in the dynamic link library GM6S32.dll."

    Code:
    LOCAL psNewRecId    AS STRING POINTER
    LOCAL sRecordId     AS ASCIIZ * 30
        
    psNewRecId = GMW_NewRecID(sRecordId, "SCOTT" & CHR$(0))
    MSGBOX @psNewRecId
    I know the function is there because when I use the VB declaration from a test VB app, the function works. Maybe I'm not declaring the function correctly? Any help would be appreciated.

    Thanks,
    Scott

    ------------------
    Scott Wolfington
    http://www.boogietools.com




    [This message has been edited by Scott Wolfington (edited March 05, 2003).]
    Scott Wolfington
    [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

  • #2
    Code:
    DECLARE FUNCTION GMW_NewRecID LIB "GM6S32.dll" alias "GMW_NewRecID" _
        (BYREF zRecId AS ASCIIZ, BYREF zUser AS ASCIIZ) AS LONG
    don't forget the alias! if this doesn't work, then the capitalization in the alias is wrong.

    --Don

    ------------------
    Don Dickinson
    Author of ddoc Print and Preview
    A dll-based print-preview engine for windows

    www.greatwebdivide.com
    Don Dickinson
    www.greatwebdivide.com

    Comment


    • #3
      The "BYREF" is really not needed. This is the PB default.

      Cheers,
      Cecil

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

      Comment


      • #4
        Thanks Don. I've tried the capitalization and alias already, but I'll try it again.

        Scott


        ------------------
        Scott Wolfington
        http://www.boogietools.com


        [This message has been edited by Scott Wolfington (edited March 05, 2003).]
        Scott Wolfington
        [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

        Comment


        • #5
          Ok, when I tried the capitalization before, I used it within the ALIAS. That was the problem. Here's my new declaration:

          DECLARE FUNCTION GMW_NewRecID LIB "GM6S32.dll" ALIAS "GMW_NewRecID" (BYREF zRecId AS ASCIIZ, BYREF zUser AS ASCIIZ) AS LONG

          Once I fixed that, I had some other fixing to do too. Here's my new code that calls it:

          Code:
              LOCAL pNewRecId     AS ASCIIZ POINTER
              LOCAL sRecordId     AS ASCIIZ * 31
              
          
              pNewRecId = GMW_NewRecID(sRecordId, "SCOTT" & CHR$(0))
              MSGBOX @pNewRecId
          I had to redefine pNewRecId to be an ASCIIZ POINTER instead of a STRING POINTER.

          Thanks guys!

          Scott

          ------------------
          Scott Wolfington
          http://www.boogietools.com


          [This message has been edited by Scott Wolfington (edited March 05, 2003).]
          Scott Wolfington
          [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

          Comment


          • #6
            No need to add the CHR$(0), by the way-- variable-length strings
            come with an automatic CHR$(0) terminator. It's a Windows thing.

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

            Comment


            • #7
              Thanks Tom. -Scott


              ------------------
              Scott Wolfington
              http://www.boogietools.com


              [This message has been edited by Scott Wolfington (edited March 05, 2003).]
              Scott Wolfington
              [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

              Comment


              • #8
                Function Type

                A very late note

                however I ahve just used some of the stuff in this thread to help me and note that
                GMW_NewRecID is of type string and it's return value ( as a string) is what you want.

                I know there is a zredID in the parameters but that is an input variable.

                DECLARE FUNCTION GMW_NewRecID LIB "GM6S32.dll" alias "GMW_NewRecID" _
                (BYREF zRecId AS ASCIIZ, BYREF zUser AS ASCIIZ) AS string

                Comment

                Working...
                X