Skip to content

Article Writing

Discuss writing articles, add your requests for articles here, or search for ideas for a new article.

This category can be followed from the open social web via the handle article-writing@forum.codeproject.com

5.4k Topics 12.4k Posts
  • wildcards

    regex help question
    2
    0 Votes
    2 Posts
    17 Views
    G
    Hi, this code should do the trick. It's an adapted function from SysInternals' FileMon application. Regards, Gertjan Schuurmans Amsterdam //--------------------------------------------------- // MatchWildCard // //Parameters // LPCTSTR pszWildCard // LPCTSTR pszFileName // //Returns // BOOL // //Remarks // // MatchWildCard tests whether the given filename matches the wildcard. pszWildCard // can contain * and ? special characters. // BOOL MatchWildCard(LPCTSTR pszWildCard, LPCTSTR pszFileName) { #define UpCase(ch) ((ch) >= 'a' && (ch) <= 'z' ? (ch) - 'a' + 'A' : (ch)) TCHAR chFile, chWild; // End of pattern? if (!*pszWildCard) { return FALSE; } // If we hit a wild card, do recursion if (*pszWildCard == '*') { pszWildCard++; while (*pszFileName && *pszWildCard) { chFile = UpCase(*pszFileName); chWild = UpCase(*pszWildCard); // See if this substring matches if (chWild == chFile || chFile == '*') { if (MatchWildCard(pszWildCard + 1, pszFileName + 1)) { return TRUE; } } // Try the next substring pszFileName++; } // See if match condition was met return (*pszWildCard == 0 || *pszWildCard == '*'); } // Do straight compare until we hit a wild card while (*pszFileName && *pszWildCard != '*') { chFile = UpCase(*pszFileName); chWild = UpCase(*pszWildCard); if (chWild == chFile || chWild == '?') { pszWildCard++; pszFileName++; } else { return FALSE; } } // If not done, recurse if (*pszFileName) { return MatchWildCard(pszWildCard, pszFileName); } // Make sure its a match return (*WildCard == 0 || *WildCard == '*'); ================== The original message was: Hi all, I need an algorith to wildcard match two strings similar to what happens when you do a dir *.* - I`d require it to support both * and ? - nothing too fancy !! Appreciate any help in this !! Thanks in advance !! Rajiv
  • wildcards

    regex help question
    2
    0 Votes
    2 Posts
    19 Views
    G
    Hi, this code should do the trick. It's an adapted function from SysInternals' FileMon application. Regards, Gertjan Schuurmans Amsterdam //--------------------------------------------------- // MatchWildCard // //Parameters // LPCTSTR pszWildCard // LPCTSTR pszFileName // //Returns // BOOL // //Remarks // // MatchWildCard tests whether the given filename matches the wildcard. pszWildCard // can contain * and ? special characters. // BOOL MatchWildCard(LPCTSTR pszWildCard, LPCTSTR pszFileName) { #define UpCase(ch) ((ch) >= 'a' && (ch) <= 'z' ? (ch) - 'a' + 'A' : (ch)) TCHAR chFile, chWild; // End of pattern? if (!*pszWildCard) { return FALSE; } // If we hit a wild card, do recursion if (*pszWildCard == '*') { pszWildCard++; while (*pszFileName && *pszWildCard) { chFile = UpCase(*pszFileName); chWild = UpCase(*pszWildCard); // See if this substring matches if (chWild == chFile || chFile == '*') { if (MatchWildCard(pszWildCard + 1, pszFileName + 1)) { return TRUE; } } // Try the next substring pszFileName++; } // See if match condition was met return (*pszWildCard == 0 || *pszWildCard == '*'); } // Do straight compare until we hit a wild card while (*pszFileName && *pszWildCard != '*') { chFile = UpCase(*pszFileName); chWild = UpCase(*pszWildCard); if (chWild == chFile || chWild == '?') { pszWildCard++; pszFileName++; } else { return FALSE; } } // If not done, recurse if (*pszFileName) { return MatchWildCard(pszWildCard, pszFileName); } // Make sure its a match return (*WildCard == 0 || *WildCard == '*'); ================== The original message was: Hi all, I need an algorith to wildcard match two strings similar to what happens when you do a dir *.* - I`d require it to support both * and ? - nothing too fancy !! Appreciate any help in this !! Thanks in advance !! Rajiv
  • Constraints

    5
    0 Votes
    5 Posts
    25 Views
    K
    For some reason the descussion pages did not make my email address available to you. Here are two: keithr@dsl-only.net (home) keith.d.rule@tek.com (work) Keith
  • Constraints

    5
    0 Votes
    5 Posts
    28 Views
    K
    For some reason the descussion pages did not make my email address available to you. Here are two: keithr@dsl-only.net (home) keith.d.rule@tek.com (work) Keith
  • Owner drawn buttons on a CDialogBar

    com tutorial
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • Owner drawn buttons on a CDialogBar

    com tutorial
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • The first request

    html
    2
    0 Votes
    2 Posts
    11 Views
    M
    I would download the file with URLDownloadToFile(). In your IBindStatusCallback::OnProgress() implementation, check the time and if it's been too long, return E_ABORT to halt the download. ATL also has a CBindStatusCallback class, which I just now found, but its description in the docs is a bit messy, so I'm not sure if you could use it to do what you want. --Mike-- ================== The original message was: I'll start it off with a request for an article: Can anyone provide a simple class to download a HTML file, with the option of setting a timeout value. (Hint: The fist bit is easy, the second requires a workaround)
  • The first request

    html
    2
    0 Votes
    2 Posts
    17 Views
    M
    I would download the file with URLDownloadToFile(). In your IBindStatusCallback::OnProgress() implementation, check the time and if it's been too long, return E_ABORT to halt the download. ATL also has a CBindStatusCallback class, which I just now found, but its description in the docs is a bit messy, so I'm not sure if you could use it to do what you want. --Mike-- ================== The original message was: I'll start it off with a request for an article: Can anyone provide a simple class to download a HTML file, with the option of setting a timeout value. (Hint: The fist bit is easy, the second requires a workaround)
  • .ico from a HICON

    question
    2
    0 Votes
    2 Posts
    17 Views
    D
    There is an article about it in MSDN -"Icons in Win32" ================== The original message was: Hi, does anybody know how can I write a .ico file from a HICON ? Thanks, Thierry
  • .ico from a HICON

    question
    2
    0 Votes
    2 Posts
    13 Views
    D
    There is an article about it in MSDN -"Icons in Win32" ================== The original message was: Hi, does anybody know how can I write a .ico file from a HICON ? Thanks, Thierry
  • OLE in-place server resizing

    com sysadmin question
    1
    0 Votes
    1 Posts
    8 Views
    No one has replied
  • OLE in-place server resizing

    com sysadmin question
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Use of TreeView

    c++ data-structures tutorial lounge learning
    1
    0 Votes
    1 Posts
    8 Views
    No one has replied
  • Use of TreeView

    c++ data-structures tutorial lounge learning
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied