Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: rounding doubles to set # decimal places Pin
b-rad31118-Jun-10 9:31
b-rad31118-Jun-10 9:31 
GeneralRe: rounding doubles to set # decimal places Pin
CPallini18-Jun-10 9:42
mveCPallini18-Jun-10 9:42 
QuestionWhere do I write user data in Win7? Pin
Koolski18-Jun-10 7:34
Koolski18-Jun-10 7:34 
AnswerRe: Where do I write user data in Win7? Pin
Code-o-mat18-Jun-10 8:29
Code-o-mat18-Jun-10 8:29 
GeneralRe: Where do I write user data in Win7? Pin
Koolski18-Jun-10 9:31
Koolski18-Jun-10 9:31 
AnswerRe: Where do I write user data in Win7? Pin
Maximilien18-Jun-10 8:35
Maximilien18-Jun-10 8:35 
GeneralRe: Where do I write user data in Win7? Pin
Koolski18-Jun-10 9:30
Koolski18-Jun-10 9:30 
GeneralRe: Where do I write user data in Win7? Pin
Code-o-mat18-Jun-10 9:46
Code-o-mat18-Jun-10 9:46 
GeneralRe: Where do I write user data in Win7? Pin
krmed18-Jun-10 10:35
krmed18-Jun-10 10:35 
AnswerRe: Where do I write user data in Win7? [edited] Pin
Ravi Bhavnani18-Jun-10 13:52
professionalRavi Bhavnani18-Jun-10 13:52 
QuestionUpgrade to VS2010 Compiler error (atlbase.h) Pin
Maximilien18-Jun-10 4:55
Maximilien18-Jun-10 4:55 
AnswerRe: Upgrade to VS2010 Compiler error (atlbase.h) Pin
Aescleal18-Jun-10 6:46
Aescleal18-Jun-10 6:46 
QuestionHow to develop a visual studio plugin to hook debugging? Pin
kcynic18-Jun-10 4:51
kcynic18-Jun-10 4:51 
AnswerRe: How to develop a visual studio plugin to hook debugging? Pin
VSVC18-Jun-10 16:00
VSVC18-Jun-10 16:00 
QuestionAssertion when Deleting the View in Splitter Window. Pin
janaswamy uday18-Jun-10 3:10
janaswamy uday18-Jun-10 3:10 
Questionboost trim Pin
gmallax17-Jun-10 23:42
gmallax17-Jun-10 23:42 
AnswerRe: boost trim Pin
Nuri Ismail17-Jun-10 23:51
Nuri Ismail17-Jun-10 23:51 
QuestionHTTP_VERB_POST Pin
john563217-Jun-10 22:27
john563217-Jun-10 22:27 
QuestionGetPrivateProfileSectionNamesA returns 0 Pin
hans.sch17-Jun-10 21:42
hans.sch17-Jun-10 21:42 
QuestionRe: GetPrivateProfileSectionNamesA returns 0 Pin
CPallini17-Jun-10 22:25
mveCPallini17-Jun-10 22:25 
AnswerRe: GetPrivateProfileSectionNamesA returns 0 Pin
hans.sch20-Jun-10 20:34
hans.sch20-Jun-10 20:34 
Tried to boil the code down to the relevant parts.
void ReadAllSections(const CString &sFileName, CStringArray &arrsSections)
{
    static const DWORD k_dwBufferInc = 10;
    DWORD dwBufferSize = 0, dwReturnedLength;
    CString sBuffer; // using a CString as a buffer to simplify memory housekeeping

    // try to read the section names; increase buffer and retry if too small
    do
    {
        dwBufferSize += k_dwBufferInc;
        dwReturnedLength = GetPrivateProfileSectionNames(sBuffer.GetBuffer(dwBufferSize - 1), dwBufferSize, sFileName);
    }
    while (dwReturnedLength == dwBufferSize - 2);

    arrsSections.RemoveAll();

    if (dwReturnedLength == 0)
    {
        // dwLastErr is 0 if the file or directory don't exist, or if it exists and contains no sections.
        // Sometimes, on a Vista Home PC, 8 is returned, although the file exists and contains sections.
        DWORD dwLastErr = GetLastError();
        AfxDebugBreak();
        return;
    }

    // split buffer into section names (I know this part could me more sophisticated)
    LPCTSTR pszCurrent = sBuffer;
    while (*pszCurrent != _T('\0'))
    {
        arrsSections.Add(pszCurrent);
        pszCurrent += _tcslen(pszCurrent) + 1;
    }
}


Let me point out once more that the AfxDebugBreak(); statement is not always executed, although always the same file name (and absolute directory) is used, and the same file is used (and exists) all the time. The MSDN documentation does not mention that a return value of 0 means failure, nor that GetLastError() should be called in that case.
GeneralRe: GetPrivateProfileSectionNamesA returns 0 Pin
CPallini20-Jun-10 21:43
mveCPallini20-Jun-10 21:43 
GeneralRe: GetPrivateProfileSectionNamesA returns 0 Pin
hans.sch21-Jun-10 20:24
hans.sch21-Jun-10 20:24 
GeneralRe: GetPrivateProfileSectionNamesA returns 0 Pin
CPallini21-Jun-10 20:54
mveCPallini21-Jun-10 20:54 
QuestionRe Question Ms PowerPoint password protected File Pin
MsmVc17-Jun-10 20:30
MsmVc17-Jun-10 20:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.