Click here to Skip to main content
16,020,345 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to recognize a original file after changing its file type? Pin
Le@rner5-Dec-11 18:45
Le@rner5-Dec-11 18:45 
GeneralRe: how to recognize a original file after changing its file type? Pin
Albert Holguin5-Dec-11 3:20
professionalAlbert Holguin5-Dec-11 3:20 
AnswerRe: how to recognize a original file after changing its file type? Pin
User 74293385-Dec-11 7:34
professionalUser 74293385-Dec-11 7:34 
GeneralRe: how to recognize a original file after changing its file type? Pin
Le@rner5-Dec-11 19:12
Le@rner5-Dec-11 19:12 
GeneralRe: how to recognize a original file after changing its file type? Pin
Richard MacCutchan5-Dec-11 22:40
mveRichard MacCutchan5-Dec-11 22:40 
AnswerRe: how to recognize a original file after changing its file type? Pin
Stefan_Lang6-Dec-11 0:01
Stefan_Lang6-Dec-11 0:01 
Questionwifstream with getline - OD OA issue Pin
jkirkerx4-Dec-11 9:14
professionaljkirkerx4-Dec-11 9:14 
AnswerRe: wifstream with getline - OD OA issue Pin
jkirkerx4-Dec-11 13:19
professionaljkirkerx4-Dec-11 13:19 
Well I got it finally, documentation is poor, but it was there.

getline - gets the line, and keeps the /n
gets - get the line, and discards the /n

I used a do loop with a while (sqlDBFile->get()) at the end, so it was chopping off the first char of the next line.

So this is what I ended up with, but I'm not sure if I need the conv at the top

C#
typedef std::codecvt<wchar_t, wchar_t, mbstate_t> nullcodecvt;
const nullcodecvt &conv =
std::use_facet<nullcodecvt>(std::wcin.getloc());
const std::locale from(std::wcin.getloc(), &conv);

std::wifstream *sqlDBFile = new std::wifstream;
sqlDBFile->open( szFilePath, std::ios_base::in );

// if the file stream opened
if (sqlDBFile->is_open() ) {

    if (_wcsicmp(szEncoding, L"UTF8") == 0 ) {
        sqlDBFile->seekg(3, std::ios::beg);
    }

    // Make a temp sql command buffer
    WCHAR *pzSQLCommand = new WCHAR[8192];
    wcsncpy_s(pzSQLCommand, 8192, L"-- SQL Command Buffer --\n", wcslen(L"-- SQL Command Buffer --\n") );

    // While file stream is in memory
    while (sqlDBFile->good() ) {
        while (!sqlDBFile->eof() ) {
            WCHAR szCommandLine[1024];
            for (int i = 0; i<1024; ++i) {
                szCommandLine[i] = 0xcccc;
            }

            sqlDBFile->getline(szCommandLine, 1024);

            // Check for Comment Line
            if (szCommandLine[0] == 0x002d)
                    continue;
            // Check for Unknown Line - Can't Remember this one
            if ((szCommandLine[0] == 0x0000) && (szCommandLine[1] == 0x0000))
                continue;
            // Check for Blank Line
            if ((szCommandLine[0] == 0x0000) && (szCommandLine[1] == 0xcccc))
                continue;

            if (_wcsicmp(szCommandLine, L"GO") == 0 ) {
                // if text = GO, terminate the buffer and execute the buffered command
                hr = pICommandText->SetCommandText( DBGUID_DBSQL, pzSQLCommand );
                hr = pICommandText->QueryInterface( IID_ICommandProperties, ( void ** ) &pICommandProperties );
                hr = pICommandText->Execute( NULL, IID_IRowset, NULL, &cRowsAffected, ( IUnknown ** ) &pIRowset );

                // Clear the main command buffer for next use
                for (int i = 0; i<8192; ++i) {
                    pzSQLCommand[i] = 0xcccc;
                }
            }
            else {
                // if text != GO, cat to main command buffer
                szCommandLine[wcslen(szCommandLine)] = L'\0';
                wcsncat_s(pzSQLCommand, 8196, szCommandLine, wcslen(szCommandLine) );
                continue;
            }
        }
    }

    delete pzSQLCommand;

    // close the sql command file
    sqlDBFile->close();
    sqlDBFile = NULL;
}

AnswerError in RtlZeroMemory [SOLVED] Pin
vishalgpt3-Dec-11 16:59
vishalgpt3-Dec-11 16:59 
AnswerRe: Error in RtlZeroMemory Pin
«_Superman_»3-Dec-11 17:18
professional«_Superman_»3-Dec-11 17:18 
GeneralRe: Error in RtlZeroMemory Pin
vishalgpt3-Dec-11 17:40
vishalgpt3-Dec-11 17:40 
GeneralRe: Error in RtlZeroMemory Pin
Erudite_Eric5-Dec-11 6:24
Erudite_Eric5-Dec-11 6:24 
GeneralRe: Error in RtlZeroMemory Pin
«_Superman_»5-Dec-11 15:50
professional«_Superman_»5-Dec-11 15:50 
GeneralRe: Error in RtlZeroMemory Pin
Erudite_Eric5-Dec-11 22:45
Erudite_Eric5-Dec-11 22:45 
AnswerRe: Error in RtlZeroMemory Pin
Albert Holguin3-Dec-11 19:13
professionalAlbert Holguin3-Dec-11 19:13 
GeneralRe: Error in RtlZeroMemory Pin
vishalgpt3-Dec-11 20:01
vishalgpt3-Dec-11 20:01 
AnswerRe: Error in RtlZeroMemory Pin
Albert Holguin3-Dec-11 20:37
professionalAlbert Holguin3-Dec-11 20:37 
GeneralRe: Error in RtlZeroMemory Pin
vishalgpt3-Dec-11 22:58
vishalgpt3-Dec-11 22:58 
GeneralRe: Error in RtlZeroMemory Pin
Albert Holguin4-Dec-11 8:19
professionalAlbert Holguin4-Dec-11 8:19 
AnswerRe: Error in RtlZeroMemory Pin
Richard MacCutchan3-Dec-11 21:27
mveRichard MacCutchan3-Dec-11 21:27 
GeneralRe: Error in RtlZeroMemory Pin
vishalgpt3-Dec-11 22:51
vishalgpt3-Dec-11 22:51 
GeneralRe: Error in RtlZeroMemory Pin
Richard MacCutchan4-Dec-11 1:26
mveRichard MacCutchan4-Dec-11 1:26 
GeneralRe: Error in RtlZeroMemory Pin
vishalgpt4-Dec-11 2:13
vishalgpt4-Dec-11 2:13 
GeneralRe: Error in RtlZeroMemory Pin
Richard MacCutchan4-Dec-11 2:53
mveRichard MacCutchan4-Dec-11 2:53 
GeneralRe: Error in RtlZeroMemory Pin
vishalgpt4-Dec-11 6:54
vishalgpt4-Dec-11 6:54 

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.