共用方式為


CWinApp::GetProfileBinary

呼叫此成員函式從應用程式的註冊或 .INI 檔的指定區段中的項目擷取二進位資料。

BOOL GetProfileBinary( 
   LPCTSTR lpszSection, 
   LPCTSTR lpszEntry, 
   LPBYTE* ppData, 
   UINT* pBytes  
);

參數

  • lpszSection
    為指定包含項目的這個部分的 NULL 結尾字串的點。

  • lpszEntry
    out 包含輸入值要擷取之 null 結尾字串的點。

  • ppData
    要接收資料之位址的指標的點。

  • pBytes
    要接收資料的大小的 UINT 的點 (以位元組為單位)。

傳回值

如果不是零,則成功,則為 0。

備註

這個成員函式不區分大小寫,因此,在 lpszSection 的 字串和 lpszEntry 參數可能不同,以免。

注意事項注意事項

GetProfileBinary 配置緩衝區並傳回其在*ppData 的位址。呼叫端負責釋放緩衝區使用 delete []

安全性注意事項安全性提示

這個函式傳回的資料不一定是以 null 結束,因此,呼叫端必須執行驗證。如需詳細資訊,請參閱 避免緩衝區滿溢

範例

CWinApp* pApp = AfxGetApp();

const TCHAR* pszKey = _T("My Section");
struct complex {
  double re, im;
} myData = { 1.4142, -0.5 };

// Write the information to the registry.

pApp->WriteProfileBinary(pszKey, _T("ComplexData"), (LPBYTE)&myData, 
   sizeof(myData));

// Read the information from the registry.

complex* pData;
UINT n;
BOOL ret = pApp->GetProfileBinary(pszKey, _T("ComplexData"), (LPBYTE*)&pData, 
   &n);

ASSERT(ret);
ASSERT(n == sizeof(complex));
ASSERT(myData.re == pData->re);
ASSERT(myData.im == pData->im);
delete [] pData; // free the buffer

如需其他範例,請參閱 CWinApp::WriteProfileBinary

需求

Header: afxwin.h

請參閱

參考

CWinApp 類別

階層架構圖表

CWinApp::GetProfileInt

CWinApp::GetProfileString