Click to See Complete Forum and Search --> : Any discrepancy using GetPrivateProfileSectionNames with W95 ?


JAL
June 7th, 2004, 05:47 AM
Hello Gurus,
does anyone know about a problem with GetPrivateProfileSectionNames and Windows 95 ?

I mean , I have a s/w that behaves correctly under NT but not under W95 :eek:

While trapping down the problem , it all ends with the function GetPrivateProfileSectionNames which returns 0 as amount of bytes read with W95 whereas returns something different with NT...

Any hint appreciated :D

Andreas Masur
June 7th, 2004, 07:14 AM
Well....can you post your code?

JAL
June 7th, 2004, 07:55 AM
This is just an excerpt ...


...
#define BUFMAXSIZE 800000
...
char m_SKBufferTemp[BUFMAXSIZE];
CString m_SKcsFileName;
... // in ctor
m_SKcsFileName.Format("%s",szFilePath);
...
bool SECTIONKEYFile::GetAllSection(void)
{
DWORD Dreturn;
Dreturn=GetPrivateProfileSectionNames(m_SKBufferTemp,sizeof(m_SKBufferTemp),LPCTSTR(m_SKcsFileName));

if(Dreturn==(sizeof(m_SKBufferTemp)-2))
{
m_SKErrorMsg=SECTIONKEY_ERROR_BUFFERIS_TOO_SMALL;
return false;
}


the problem is that if I run it under NT on a .INI , I got Dreturn = ,say,32 but if run under w95 , I got = 0 :confused:

JAL
June 10th, 2004, 02:22 AM
On top of it ,
I have just made a little console app whith a simple call to 'GetPrivateProfileSectionNames' and I got the same behavior than with my bigger s/w.


int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
CString path = AfxGetApp()->m_pszHelpFilePath;
path = path.Left(path.ReverseFind('\\')+1);
path+="test.ini";
DWORD iCount = 0;
char pszReturnBuffer[80000];

cout << "Testing function GetPrivateProfileSectionNames :" << endl;

iCount = GetPrivateProfileSectionNames(pszReturnBuffer, sizeof(pszReturnBuffer),path);

if ( iCount > 0 )
{
cout << "success ! read : "<< iCount << " characters..."<< endl;
getche();
}
else
{
cout << "failed ! nothing read..." << endl;
getche();
}

}

return nRetCode;
}


the only thing I see is the buffer size which is bigger than 32K ...:ehh:

JAL
June 11th, 2004, 09:45 AM
Wew ! decreasing size of th buffer under 32k made it work !
I got now the same behavior with NT and 95.
I leave the post just in case :wave: