0

I have a project where a large amount of the source code is unavailable. There's an IntfCast exception in one of the functions and I've beens stepping through the application with the CPU debugger and have identified the function containing the casting operation and one of the classes involved, but I can't identify the other class. I am trying to replicate the error but the casting operation I'm attempting is not calling IntfCast. How do I get the cast to call IntfCast?

Thank you.

mnuzzo
  • 3,529
  • 4
  • 26
  • 29
  • 1
    Is this a more cryptic variant of this: http://stackoverflow.com/questions/5419901/passing-nil-as-a-parameter-in-place-of-a-tcomponent ? – Cosmin Prund Mar 30 '11 at 12:52
  • It's related. This is actually closer to the source of the problem. I've identified the function that the error is actually occurring in. The thing is, I don't have the source code so I'm trying to recreate the error in code that I'm writing so I know what to look for while stepping through the CPU instructions. – mnuzzo Mar 30 '11 at 12:57

2 Answers2

2

IntfCast is called when you try to cast an object or an interface to an other interface. Here's some sample code that internally calls IntfCast:

type ISomeInterface = interface
[guid-goes-here, use ctr+g to obtain unique guid]
  procedure DoSomething;
end;

var X: TComponent;
    i: IUnknown;
begin
  (X as ISomeInterface).DoSomething;
  (i as ISomeInterface).DoSomething;
end;
Cosmin Prund
  • 25,498
  • 2
  • 60
  • 104
0

IntfCast is called in dynamic casting.

Read this http://hi.baidu.com/007ware/blog/item/de69ed3ce554890abba16726.html

PA.
  • 28,486
  • 9
  • 71
  • 95