IMDEmbedded 接口

IMDEmbedded 接口是用于管理嵌入式 PowerPivot 数据库或表格模型数据库的公共接口。 接口继承自 IPersistStream 接口。 该接口允许执行以下作:

  • 获取容器文档中嵌入流的标识符。

  • 设置包含文档的 URL。

  • 设置一个标志以指示嵌入应用程序是否位于托管环境中。

  • 设置嵌入应用程序使用的临时文件的路径。

  • 取消当前嵌入的作。

  • 获取流的估计大小(以字节为单位),以保存嵌入的对象。 从 IPersistStream 继承。

  • 验证嵌入数据库自上次保存以来是否已更改。 从 IPersistStream 继承。

  • 将嵌入式数据库加载到本地或进程内引擎。 从 IPersistStream 继承。

  • 将本地数据库或进程内数据库保存到容器文档中的嵌入流。 从 IPersistStream 继承。

参考文献

以下引用记录IMDEmbedded了 msmd.h 头文件中所示的接口。

源文件:PXOEmbeddedData.idl

[  
  local,                            
  object,                           
  uuid(6B6691CF-5453-41c2-ADD9-4F320B7FD421),                       
  pointer_default(unique)           
]  
interface IMDEmbeddedData : IPersistStream  
{  
 [id(1), helpstring("Set flag indicating if the application is in a hosted environment")]   
 HRESULT SetHosted(  
  [in] BOOL in_fIsHosted);  
  
 [id(2), helpstring("Set the URL for the document containing the embedded stream")]   
 HRESULT SetContainerURL(  
  [in] BSTR in_bstrURL);  
  
 [id(3), helpstring("Get identifier used to look up embedded stream in container document")]   
 HRESULT GetStreamIdentifier(  
  [out, retval] BSTR* out_pbstrStreamId);  
  
 [id(4), helpstring("Set the path used by the embedding application for temporary files")]   
 HRESULT SetTempDirPath(  
  [in]  BSTR in_bstrPath);  
  
 [id(5), helpstring("Cancel the current operation")]   
 HRESULT Cancel();  
};  

IMDEmbeddedData::GetStreamIdentifier

HRESULT GetStreamIdentifier (  
    [out, retval] BSTR * out_pbstrStreamId  
    )  

DESCRIPTION

获取主机应用程序用于容器文档中嵌入流的标识符。

参数

out_pbstrStreamId
指定流标识符的位置。

返回值

S_OK
已成功返回流标识符。

S_FALSE
没有流标识符。

E_FAIL
访问流标识符时出错。

注解

若要验证当前连接是否包含嵌入式数据库,用户应检查 OLE DB 连接属性中DBPROP_MSMD_EMBEDDED_DATA属性的值。

DBPROP_MSMD_EMBEDDED_DATA的可能值为:

名称 价值 定义
DBPROPVAL_EMBED_NONE 0x00 没有可用的嵌入式数据库
DBPROPVAL_EMBED_EMBEDDED 0x01 当前应用程序包含嵌入式数据库
DBPROPVAL_EMBED_LINKED 0x02 嵌入式数据库托管在远程应用程序中(即 SharePoint Server)

来源

[id(1), helpstring("Get identifier used to look up embedded stream in container document")]   
 HRESULT GetStreamIdentifier(  
  [out, retval] BSTR* out_pbstrStreamId);  

IMDEmbeddedData::SetContainerURL

HRESULT SetContainerURL (  
    [in] BSTR in_bstrURL  
    )  

DESCRIPTION

设置包含嵌入流的文件的 URL。

参数

in_bstrURL
指定包含文档的 URL。

返回值

S_OK
已成功设置容器 URL。

E_FAIL
设置容器 URL 时出错。

来源

[id(2), helpstring("Set the URL for the document containing the embedded stream")]   
 HRESULT SetContainerURL(  
  [in] BSTR in_bstrURL);  

IMDEmbeddedData::SetHosted

HRESULT SetHosted (  
    [in] BOOL in_fIsHosted  
    )  

DESCRIPTION

设置一个标志以指示嵌入应用程序是否位于托管环境中。

参数

in_ftHosted
如此 如果调用方在服务应用程序中托管(如 IIS)。

返回值

S_OK
已成功设置标志。

E_FAIL
设置标志时出错。

来源

[id(5), helpstring("Set flag indicating if the application is in a hosted environment")]   
 HRESULT SetHosted(  
  [in]  BOOL in_fIsHosted);  

IMDEmbeddedData::SetTempDirPath

HRESULT SetTempDirPath (  
    [in] BSTR in_bstrPath  
    )  

DESCRIPTION

设置嵌入应用程序使用的临时文件的路径。

参数

in_bstrPath
主机应用程序用于临时文件的路径。

返回值

S_OK
已成功设置临时文件目录。

E_FAIL
设置路径时出错。

来源

[id(4), helpstring("Set the path used by the host application for temporary files")]   
 HRESULT SetTempDirPath(  
  [in]  BSTR in_bstrPath);  

IMDEmbeddedData::Cancel

HRESULT Cancel ( void )  

DESCRIPTION

取消当前嵌入式数据库作

参数

没有。

返回值

S_OK
作已成功取消。

DB_E_CANTCANCEL
当前没有可取消的作。

E_FAIL
取消嵌入作时出错。

来源

[id(5), helpstring("Cancel the current operation")]   
 HRESULT Cancel();  

IMDEmbeddedData::GetSizeMax (IPersistStream::GetSizeMax)

HRESULT GetSizeMax (  
    [out] ULARGE_INTEGER * out_pcbSize  
    )  

DESCRIPTION

获取流的估计大小(以字节为单位),以保存嵌入的对象。 从 IPersistStream 继承。

参数

in_bstrPath
嵌入数据库映像的估计大小(以字节为单位)。

返回值

S_OK
已成功获取大小。

E_FAIL
获取大小时出错。

IMDEmbeddedData::IsDirty (IPersistStream::IsDirty)

HRESULT IsDirty ( void )  

DESCRIPTION

验证嵌入数据库自上次保存以来是否已更改。 从 IPersistStream 继承。

参数

没有

返回值(s)

S_OK
自上次保存数据库以来,数据库已更改。

S_FALSE
自上次保存数据库以来,该数据库尚未更改。

E_FAIL
获取数据库状态时出错。

IMDEmbeddedData::Load (IPersistStream::Load)

HRESULT Load (   
    [in] IStream * in_pStm   
    )  

DESCRIPTION

将嵌入式数据库加载到本地或进程内引擎。 从 IPersistStream 继承。

参数

in_pStm
指向从中加载嵌入数据库的流接口的指针。

返回值(s)

S_OK
已成功加载数据库。

E_OUTOFMEMORY
没有足够的内存来加载数据库。

E_FAIL
加载数据库时出错,不同于 E_OUTOFMEMORY

IMDEmbeddedData::Save (IPersistStream::Save)

HRESULT Save (   
    [in] IStream * in_pStm,  
    [in] BOOL in_fClearDirty  
    )  

DESCRIPTION

将本地数据库或进程内数据库保存到容器文档中的嵌入流。 从 IPersistStream 继承。

参数

in_pStm
指向流接口的指针,指向保存嵌入的数据库的位置。

in_fClearDirty
指示是否应在此作后清除脏标志的标志。

返回值(s)

S_OK
已成功保存数据库。

STG_E_CANTSAVE
保存数据库时出错,不同于 STG_E_MEDIUMFULL

STG_E_MEDIUMFULL
无法保存数据库,因为存储设备上没有剩余空间。