Click here to Skip to main content
16,008,490 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: An unexplained compiler error (C2039) Pin
Colin Angus Mackay8-May-04 0:31
Colin Angus Mackay8-May-04 0:31 
GeneralRe: An unexplained compiler error (C2039) Pin
Prakash Nadar8-May-04 22:57
Prakash Nadar8-May-04 22:57 
GeneralRe: An unexplained compiler error (C2039) Pin
Anonymous9-May-04 5:01
Anonymous9-May-04 5:01 
QuestionHow to get _DSpreadSheet's point from handle? Pin
wl@syntc.com.cn7-May-04 20:45
wl@syntc.com.cn7-May-04 20:45 
GeneralProtocol Validation Pin
Kannan Ramanathan7-May-04 20:03
Kannan Ramanathan7-May-04 20:03 
Generalrecursive directory searching Pin
Ryan McDermott7-May-04 16:12
Ryan McDermott7-May-04 16:12 
GeneralRe: recursive directory searching Pin
nguyenvhn7-May-04 17:17
nguyenvhn7-May-04 17:17 
GeneralRe: recursive directory searching Pin
Joe Woodbury7-May-04 17:40
professionalJoe Woodbury7-May-04 17:40 
Normally, I recommend using MFC classes whenever possible except for CFileFind, which I find to be abhorent. I'd also normally give you some hints and have you learn for yourself, but I don't feel like it, so here is a non-MFC program for you:

#define WIN32_LEAN_AND_MEAN
#include < windows.h>
#include < shlwapi.h>
#include < stdio.h>
#include < tchar.h>

#pragma comment(lib, "shlwapi.lib")

inline
bool IsDots(LPCTSTR pFileName)
{
    int i = 0;
    while (pFileName[i])
    {
        if (pFileName[i++] != '.')
            return false;
    }
    return true;
}

bool Walk(LPCTSTR pDirToFind, LPTSTR pFinalPath)
{
    bool foundDir = false;

    WIN32_FIND_DATA findData;
    HANDLE hFind = ::FindFirstFile(_T("*"), &findData);
    if (hFind != INVALID_HANDLE_VALUE)
    {
        do
        {
            if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            {
                if (::CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, findData.cFileName, -1, pDirToFind, -1) == CSTR_EQUAL)
                {
                    ::GetCurrentDirectory(MAX_PATH, pFinalPath);
                    PathAddBackslash(pFinalPath);
                    _tcscat(pFinalPath, findData.cFileName);
                    foundDir = true;
                }
                else if (!IsDots(findData.cFileName))
                {
                    ::SetCurrentDirectory(findData.cFileName);
                    foundDir = Walk(pDirToFind, pFinalPath);
                    ::SetCurrentDirectory(_T(".."));
                }
            }

        } while (!foundDir && ::FindNextFile(hFind, &findData));

        ::FindClose(hFind);
    }
    return foundDir;
}

int _tmain(int argc, TCHAR* argv[])
{
    if (argc != 2)
    {
        _putts(_T("FindDir <<dir>>"));
        return 1;
    }

    TCHAR finalPath[MAX_PATH];
    if (!Walk(argv[1], finalPath))
    {
        _tprintf(_T("Directory \"%s\" could not be found\n"), argv[1]); 
        return 1;
    }

    _tprintf(_T("Directory path is: %s\n"), finalPath);

    return 0;
}


Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke

GeneralRe: recursive directory searching Pin
2249177-May-04 19:27
2249177-May-04 19:27 
GeneralRe: recursive directory searching Pin
Joe Woodbury8-May-04 8:36
professionalJoe Woodbury8-May-04 8:36 
GeneralINI File/MFC Pin
ThongNguyen7-May-04 16:07
ThongNguyen7-May-04 16:07 
GeneralRe: INI File/MFC Pin
Joe Woodbury7-May-04 17:43
professionalJoe Woodbury7-May-04 17:43 
GeneralRe: INI File/MFC Pin
Anonymous7-May-04 18:11
Anonymous7-May-04 18:11 
QuestionHow can I calculate??? help Pin
Snyp7-May-04 15:00
Snyp7-May-04 15:00 
AnswerRe: How can I calculate??? help Pin
valikac7-May-04 18:47
valikac7-May-04 18:47 
GeneralRe: How can I calculate??? help Pin
Rafael Fernández López7-May-04 23:14
Rafael Fernández López7-May-04 23:14 
GeneralRe: How can I calculate??? help Pin
Snyp8-May-04 13:04
Snyp8-May-04 13:04 
Generalwebbrowser control in dll Pin
dilip_sarangi7-May-04 14:59
sussdilip_sarangi7-May-04 14:59 
GeneralRe: webbrowser control in dll Pin
Rafael Fernández López7-May-04 23:17
Rafael Fernández López7-May-04 23:17 
GeneralHandling Minimize event Pin
Dev5787-May-04 12:55
Dev5787-May-04 12:55 
GeneralRe: Handling Minimize event Pin
Garth J Lancaster7-May-04 14:09
professionalGarth J Lancaster7-May-04 14:09 
GeneralRe: Handling Minimize event Pin
Joe Woodbury7-May-04 17:44
professionalJoe Woodbury7-May-04 17:44 
GeneralRe: Handling Minimize event Pin
nguyenvhn7-May-04 22:29
nguyenvhn7-May-04 22:29 
Generallistbox custom draw Pin
roel_7-May-04 12:46
roel_7-May-04 12:46 
GeneralRe: listbox custom draw Pin
Joe Woodbury7-May-04 17:47
professionalJoe Woodbury7-May-04 17:47 

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.