Skip to content

Instantly share code, notes, and snippets.

@mattcox

mattcox/getInstance.cpp

Last active Jul 12, 2018
Embed
What would you like to do?
Demonstrates how to get a PackageInstance from a ILxItem COM interface. If you pass this function an item, it will return the class that it derives from, as long as it is one of your classes. Obviously, change the class name to whatever your class is called, as well as the server name!
Instance *
getInstance (
ILxUnknownID item)
{
CLxLoc_PackageInstance pkgInstance (item);
CLxSpawner <Instance> spawn ("myInstance");
if (pkgInstance.test ())
return spawn.Cast (pkgInstance);
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment