Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

CWinApp::WriteProfileBinary

Call this member function to write binary data into the specified section of the application's registry or .INI file.

BOOL WriteProfileBinary( 
   LPCTSTR lpszSection, 
   LPCTSTR lpszEntry, 
   LPBYTE pData, 
   UINT nBytes  
);
lpszSection

Points to a null-terminated string that specifies the section containing the entry. If the section does not exist, it is created. The name of the section is case independent; the string may be any combination of uppercase and lowercase letters.

lpszEntry

Points to a null-terminated string that contains the entry into which the value is to be written. If the entry does not exist in the specified section, it is created.

pData

Points to the data to be written.

nBytes

Contains the number of bytes to be written.

Nonzero if successful; otherwise 0.

This example uses CWinApp* pApp = AfxGetApp(); to get at the CWinApp class illustrating a way that WriteProfileBinary and GetProfileBinary can be used from any function in an MFC application.

CWinApp* pApp = AfxGetApp();

CString strSection = _T("My Section");
CString strItem = _T("My Binary Item");
double myData = 123.456e12;

pApp->WriteProfileBinary(strSection, strItem, (LPBYTE)&myData, sizeof(myData));
double *pData;
UINT n;
pApp->GetProfileBinary(strSection, strItem, (LPBYTE*)&pData, &n);
ASSERT(n == sizeof(myData));
ASSERT(myData = *pData);
delete [] pData;  // free the buffer

For another example, see the example for CWinApp::GetProfileBinary.

Header: afxwin.h

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.