No announcement yet.

Really fundamental instance puzzle

  • Filter
  • Time
  • Show
Clear All
new posts

  • Really fundamental instance puzzle

    Take a very simple program, such as the HELLO.BAS program supplied
    with PBDLL 6 in the SAMPLES directory. Add the line,

    msgbox str$(curInst)

    where curInst is the first parameter passed to WinMain. Compile
    and then run n (n > 1) instances of the program. I get n message
    boxes all saying 4194304. I thought the current instance handle
    value should be different for each instance of a program. Why
    are mine all the same?

    Keith Waters


  • #2
    This could be a puzzle for Win16 developers only.
    Under Win32 all processes are independent and address x in process 1 doesn't have the same phisical location as address x in process 2.

    Numeration of addresses begins from 0 in each process.
    Because a set of modules, which OS automatic loads in each process, is "permanent", an address of started program is also fixed.

    E-MAIL: [email protected]


    • #3
      Thanks Semen

      I realise you have put your finger exactly on the truth. It's
      just that I had been confused by Petzold's statement in his book,

      "Each copy is called an 'instance", and each has a different
      hInstance value."

      Thanks again for your reply.



      [This message has been edited by Keith Waters (edited January 27, 2001).]