Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than Interfaces, prefix the name with the module name and a period.
IClassFactory2 (Interfaces)
.
This interface is used to instantiate a COM Object with a licence key
C# Definition:
[ComImport]
[Guid("B196B28F-BAB4-101A-B69C-00AA00341D07")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IClassFactory2
{
/// <summary>
/// the standard create instance (without licence)
/// </summary>
/// <param name="unused">must be set to null</param>
/// <param name="iid">the Guid of the COM class to create</param>
/// <returns>an instance of the COM class</returns>
[return: MarshalAs(UnmanagedType.Interface)]
Object CreateInstance(
[In, MarshalAs(UnmanagedType.Interface)] Object unused,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid iid);
void LockServer(Int32 fLock);
IntPtr GetLicInfo(); // TODO : an enum called LICINFO
[return: MarshalAs(UnmanagedType.BStr)]
String RequestLicKey(
[In, MarshalAs(UnmanagedType.U4)] int reserved);
/// <summary>
/// create an instance of the COM class thanks to a licence key
/// </summary>
/// <param name="pUnkOuter">don't know what it is, set to null</param>
/// <param name="pUnkReserved">must be set to null</param>
/// <param name="iid">the Guid of the COM class to create</param>
/// <param name="bstrKey">the licence key</param>
/// <returns>an instance of the COM class</returns>
[return: MarshalAs(UnmanagedType.Interface)]
Object CreateInstanceLic(
[In, MarshalAs(UnmanagedType.Interface)] object pUnkOuter,
[In, MarshalAs(UnmanagedType.Interface)] object pUnkReserved,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid iid,
[In, MarshalAs(UnmanagedType.BStr)] string bstrKey);
}
VB Definition:
<ComImport()> _
<Guid("B196B28F-BAB4-101A-B69C-00AA00341D07")> _
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Interface IClassFactory2
''' <summary>
''' the standard create instance (without licence)
''' </summary>
''' <param name="unused">must be set to null</param>
''' <param name="iid">the Guid of the COM class to create</param>
''' <returns>an instance of the COM class</returns>
<[return]: MarshalAs(UnmanagedType.[Interface])> _
Private Function CreateInstance(_
<[In](), MarshalAs(UnmanagedType.[Interface])> ByVal unused As Object,_
<[In](), MarshalAs(UnmanagedType.LPStruct)> ByVal iid As Guid) As Object
Private Sub LockServer(ByVal fLock As Int32)
Private Function GetLicInfo() As IntPtr
' TODO : an enum called LICINFO
<[return]: MarshalAs(UnmanagedType.BStr)> _
Private Function RequestLicKey(<[In](), MarshalAs(UnmanagedType.U4)> ByVal reserved As Integer) As String
''' <summary>
''' create an instance of the COM class thanks to a licence key
''' </summary>
''' <param name="pUnkOuter">don't know what it is, set to null</param>
''' <param name="pUnkReserved">must be set to null</param>
''' <param name="iid">the Guid of the COM class to create</param>
''' <param name="bstrKey">the licence key</param>
''' <returns>an instance of the COM class</returns>
<[return]: MarshalAs(UnmanagedType.[Interface])> _
Private Function CreateInstanceLic(_
<[In](), MarshalAs(UnmanagedType.[Interface])> ByVal pUnkOuter As Object,_
<[In](), MarshalAs(UnmanagedType.[Interface])> ByVal pUnkReserved As Object,_
<[In](), MarshalAs(UnmanagedType.LPStruct)> ByVal iid As Guid,_
<[In](), MarshalAs(UnmanagedType.BStr)> ByVal bstrKey As String) As Object
End Interface
The "Object" return by methods can be cast to the specified type.
Exemple :
String LicenceKey = "haha";
IClassFactory2 icf2 = Ole32.CoGetClassObject(
typeof(Interop.MyComLibrary.ComMyLibraryClass).GUID,
CLSCTX.CLSCTX_LOCAL_SERVER, new System.IntPtr(),
typeof(IClassFactory2).GUID) as IClassFactory2;
Interop.MyComLibrary.IMyComClass instance = icf2.CreateInstanceLic(
null, null, typeof(Interop.MyComLibrary.IMyComClass).GUID, LicenceKey) as Interop.MyComLibrary.IMyComClass;
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
Click to read this page
3/14/2008 10:48:40 AM - -194.25.187.120
The CoGetClassObject API
3/16/2007 8:07:23 AM - -24.248.164.2
Please edit this page!
Do you have...
helpful tips?
corrections to the existing content?
alternate definitions?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.