导航:  COM (Component Object Model) > COM Procedures >

AfxNewCom (overload)

上一页返回章节概述下一页

Description

 

Loads the specified library from file and creates an instance of an object.

 

FreeBASIC syntax

 

FUNCTION AfxNewCom OVERLOAD ( _

  BYREF wszLibName AS CONST WSTRING, _

  BYREF rclsid AS CONST CLSID, _

  BYREF riid AS CONST IID, _

  BYREF wszLicKey AS WSTRING _

) AS ANY PTR

 

FUNCTION AfxNewCom OVERLOAD ( _

  BYREF wszLibName AS CONST WSTRING, _

  BYREF wszClsid AS CONST WSTRING, _

  BYREF riid AS CONST WSTRING, _

  BYREF wszLicKey AS WSTRING = "" _

) AS ANY PTR

 

FUNCTION AfxNewCom OVERLOAD ( _

  BYREF wszLibName AS CONST WSTRING, _

  BYREF wszClsid AS CONST WSTRING, _

  BYREF wszIid AS CONST WSTRING, _

  BYREF wszLicKey AS WSTRING = "" _

) AS ANY PTR

 

Parameters

 

wszLibName

[in] Full path where the library is located.

rclsid

[in] The CLSID (class identifier) associated with the data and code that will be used to create the object.

wszClsid

[in] Same as rclsid but in unicode string format.

riid

[in] A reference to the identifier of the interface to be used to communicate with the object.

wszIid

[in] Same as riid but in unicode string format.

wszLicKey

[in] The license key.

 

Return value

 

If it succeeds, returns a reference to the requested interface; otherwise, it returns null.

 

Remarks

 

Not every component is a suitable candidate for use under this overloaded AfxNewCom function.

?/SPAN> Only in-process servers (DLLs) are supported.
?/SPAN> Components that are system components or part of the operating system, such as XML, Data Access, Internet Explorer, or DirectX, aren't supported
?/SPAN> Components that are part of an application, such Microsoft Office, aren't supported.
?/SPAN> Components intended for use as an add-in or a snap-in, such as an Office add-in or a control in a Web browser, aren't supported.
?/SPAN> Components that manage a shared physical or virtual system resource aren't supported.
?/SPAN> Visual ActiveX controls aren't supported because they need to be initilized and activated by the OLE container.

 

Note

 

Do not use DyLibFree to unload the library once you have got a valid reference to an interface or your application will GPF. Before calling DyLibFree, all the interface references must be released. If you don't need to unload the library until the application ends, then you don't need to call DyLibFree because CoUninitialize closes the COM library on the current thread, unloads all DLLs loaded by the thread, frees any other resources that the thread maintains, and forces all RPC connections on the thread to close.

 

Include file

 

AfxCOM.inc