VB6 App.hInstance returns a constant

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi folks,

I compiled two different COM+ componets wrote in VB6 that implements a method whose execution simplereturn app.Hisntance. Whenever I call those components, no metter if they are registered with COM+ or only registered in windows (using regsvr), the value is always the same, and is constant!!!

How could this happen? Is this by somehow related to .Net (I'm testing the code under Windows XP).

Cheers,

Eric.
 
Eric,
How could this happen?

The hInstance on Win32 is only unique within the same process (it's
actually the load base address of the DLL). It will be the same in all
process the DLL is loaded into unless the DLL is relocated. So it's
usually not meaningful to share hInstance values cross processes.

Is this by somehow related to .Net (I'm testing the code under Windows XP).

No



Mattias
 
Hi Again Mattias,

Thanks for replying this one too. :)
I actually knew the meaning of the hInstance, and that why this test is driving me crazy. Those components are returning the same value *always* even, if I run it in different machines. Since it's a handle to DLL's memory address, I was expecting to see it change. But is returning a constant (285212672).

Since I'm not a VB programmer, I guessed that I was doing some stupid error in VB, (even being this a one line code), but for my surprise it's not. So came the second guess: those components was being controled by .Net what could explain the value returned. But even in other machine, that was the same result. Then came my 3 guess: the value has become invalid under .Net and it is returning some kind of constant.

Is that the case?

Cheers,

Eric

ps.: all the source come from a discussion with a frien that came up with an idea to validate his components code execution trough the use of a "kind of" callback function. His components call a validation componet method , passing the hInstance to it. The validation component then call another method from the callers component (trough late bind) that should return again hInstance, and the check to see if they're the same, and for me this doesn't seem a good strategy.
 
Eric,
Those components are returning the same value *always* even, if I run it in different machines.
Since it's a handle to DLL's memory address, I was expecting to see it change. But is returning a constant (285212672).

Right, 285212672 = 0x11000000, which is the default base address in VB
projects. It can be changed in the project properties.

Is that the case?

No. Again, this has nothing to do with .NET.

ps.: all the source come from a discussion with a frien that came up with an idea to validate his components code execution
trough the use of a "kind of" callback function. His components call a validation componet method , passing the hInstance to it.
The validation component then call another method from the callers component (trough late bind) that should return again hInstance,
and the check to see if they're the same, and for me this doesn't seem a good strategy.

I don't quite see the point of that either.



Mattias
 
Right, 285212672 = 0x11000000, which is the default base address in V
projects. It can be changed in the project properties

In other words.. it was a stupid mistake from the programmer (ie. myself) ;}

Thnaks again for the time. I own you two..

Cheers

Eric
 
Back
Top