Announcement

Collapse
No announcement yet.

GetModuleHandle (BYVAL 0) vs. GetModuleHandle($NUL)

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

  • GetModuleHandle (BYVAL 0) vs. GetModuleHandle($NUL)

    Hi there,

    this works fine :
    hICONInfo = LoadIcon( GetModuleHandle(BYVAL 0), BYVAL MAKLNG(1003,0) )

    but when i use $NUL hIconInfo is 0 :
    hICONInfo = LoadIcon( GetModuleHandle($NUL), BYVAL MAKLNG(1003,0) )

    What is $NUL ? A STRPTR, a VARPTR or simply 0 ?

    Ralph

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

  • #2
    Ralph,

    %NULL should be a numeric value where your equate is a string
    equate.

    I usually use ByVal %NULL as the parameter.

    Regards,

    [email protected]

    ------------------
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com

    Comment


    • #3
      $NUL is a built-in string equate, %NULL is a user-defined equate (it is defined in WIN32API.INC for convenience).

      To be clear, using $NUL is the same as using CHR$(0). That is, it specifies a 1 byte string containing one CHR$(0).

      Therefore, your API call code could be rewritten to show the problem more clearly:
      Code:
      CALL GetModuleHandle(CHR$(0))
      ...which is clearly wrong. As Steve says, you need to pass the value zero to the API. If you tried BYCOPY $NUL, you'd be sending the address of a zero byte, which would be wrong for the API context.

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

      Comment


      • #4
        I think that $NUL = CHR$(0) instead of $NUL = "" and PB operates with it like with string with length = 1.
        For example, Len("a" + $NUL + "a") = 3.

        Imagine
        Code:
        Sub ab (s As Asciiz)
        If to call ab "", PB will transfer 0& as address of s. That's why GetModuleHandle("") will work.

        But in case
        Code:
        Dim a As Asciiz * 100
        ab a
        PB transfers a pointer to a byte with value 0.
        It's not the same

        PS. I saw Lance answer too late.

        [This message has been edited by Semen Matusovski (edited May 20, 2001).]

        Comment


        • #5
          Thanks for the help. I'll use GetModuleHandle(BYVAL 0)
          to get the current instance.
          Just to be shure : Literals are STRPTR. Aren't they ?

          rgds
          Ralph



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

          Comment


          • #6
            Semen,

            as i remember i found GetModuleHandle($NUL) in
            your src postings too.

            Ralph

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

            Comment


            • #7
              Ralph --
              I searched in POFFS2
              No one GetModuleHandle($NUL) found.
              BTW, it seems to me that I never used $NUL at all, not in GetModuleHandle only (%NULL - yes)



              ------------------
              E-MAIL: [email protected]

              Comment

              Working...
              X