共用方式為


IBackgroundCopyFile::GetLocalName 方法 (bits.h)

擷取檔案的本機名稱。

語法

HRESULT GetLocalName(
  [out] LPWSTR *pVal
);

參數

[out] pVal

Null 終止的字串,其中包含用戶端上的檔名。 此名稱為完整名稱。 完成時,呼叫 CoTaskMemFree 函式以釋放 ppName

傳回值

此方法會在成功時 傳回S_OK ,或發生錯誤的其中一個標準 COM HRESULT 值。

備註

當您呼叫 IBackgroundCopyJob 介面的 AddFileAddFileSet 方法時,會設定本機檔名。

範例

下列範例示範如何從 擷取本機和遠端檔名和進度相關信息
IBackgroundCopyFile 介面。 此範例假設 IBackgroundCopyFile 介面指標有效。

IBackgroundCopyFile* pFile;
HRESULT hr;
WCHAR* pszLocalFileName = NULL;
WCHAR* pszRemoteFileName = NULL;
WCHAR  szPercentComplete[4+1];
BG_FILE_PROGRESS Progress;

hr = pFile->GetLocalName(&pszLocalFileName);
if (SUCCEEDED(hr))
{
  hr = pFile->GetRemoteName(&pszRemoteFileName);
  if (SUCCEEDED(hr))
  {
    pFile->GetProgress(&Progress);
    if (BG_SIZE_UNKNOWN == Progress.BytesTotal) 
    {
      StringCchPrintf(szPercentComplete, sizeof(szPercentComplete), L"0%%");
    } 
    else 
    {
      StringCchPrintf(szPercentComplete, sizeof(szPercentComplete), L"%I64d%%", 
          100*Progress.BytesTransferred/Progress.BytesTotal); 
    }
    //Do something with the file names and progress information.
  }
}
if (pszLocalFileName)
  CoTaskMemFree(pszLocalFileName);
if (pszRemoteFileName)
  CoTaskMemFree(pszRemoteFileName);

規格需求

需求
最低支援的用戶端 Windows XP
最低支援的伺服器 Windows Server 2003
目標平台 Windows
標頭 bits.h
程式庫 Bits.lib
Dll QmgrPrxy.dll

另請參閱

IBackgroundCopyFile

IBackgroundCopyFile::GetRemoteName

IBackgroundCopyJob::AddFile

IBackgroundCopyJob::AddFileSet