CWinApp::GetProfileBinary
Visual Studio 2012
Call this member function to retrieve binary data from an entry within a specified section of the application's registry or .INI file.
BOOL GetProfileBinary( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPBYTE* ppData, UINT* pBytes );
This member function is not case sensitive, so the strings in the lpszSection and lpszEntry parameters may differ in case.
Note
|
|---|
|
GetProfileBinary allocates a buffer and returns its address in *ppData. The caller is responsible for freeing the buffer using delete []. |
Security Note
|
|---|
|
The data returned by this function is not necessarily NULL terminated, and the caller must perform validation. For more information, see Avoiding Buffer Overruns. |
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
For an additional example, see CWinApp::WriteProfileBinary.
Note