Click here to Skip to main content
16,016,460 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help with threads Pin
Rajesh R Subramanian9-Jul-09 22:52
professionalRajesh R Subramanian9-Jul-09 22:52 
GeneralRe: Help with threads Pin
Roger Stoltz10-Jul-09 1:03
Roger Stoltz10-Jul-09 1:03 
GeneralRe: Help with threads Pin
Rajesh R Subramanian10-Jul-09 1:08
professionalRajesh R Subramanian10-Jul-09 1:08 
Questionmfc tab problem Pin
DevelopmentNoob9-Jul-09 16:15
DevelopmentNoob9-Jul-09 16:15 
AnswerRe: mfc tab problem Pin
«_Superman_»9-Jul-09 19:47
professional«_Superman_»9-Jul-09 19:47 
GeneralRe: mfc tab problem Pin
DevelopmentNoob16-Jul-09 21:18
DevelopmentNoob16-Jul-09 21:18 
QuestionIs it safe to cast from LPBYTE to LPSTR to LPBYTE ? Pin
Mike the Red9-Jul-09 13:47
Mike the Red9-Jul-09 13:47 
AnswerRe: Is it safe to cast from LPBYTE to LPSTR to LPBYTE ? Pin
Stuart Dootson9-Jul-09 14:19
professionalStuart Dootson9-Jul-09 14:19 
Yes, you can cast LPBYTE to LPSTR without really worrying too much.

Rather than use CString, though, I'd probably use either STL algorithms (because LPBYTE and LPSTR can both be treated as STL iterators) or Boost algorithms[^] (which are actually a lot easier to use than the documentation can make it appear), because they will act on your BYTE array, whereas a CString manages its own buffer.

Here's an example of how to find a substring in a BYTE buffer (I've used unsigned char* because I'm testing on OS X, not Windows, so I don't have a BYTE type!):

#include <algorithm>
#include <iostream>

int main()
{
   unsigned char buffer[] = { 1, 2, 3, 'H', 'e', 'l', 'l', 'o', 34, 12 };
   unsigned char* bufferEnd = buffer + sizeof(buffer);
   char lookFor[] = "Hello";
   char* lookForEnd = lookFor + strlen(lookFor);

   unsigned char* where = std::search(buffer, bufferEnd, (unsigned char*)lookFor, (unsigned char*)lookForEnd);
   
   std::cout << std::distance(buffer, where) << std::endl; // Shows the offset of Hello in the buffer == 3
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

JokeThanks, Stuart! -nt- Pin
Mike the Red9-Jul-09 15:43
Mike the Red9-Jul-09 15:43 
QuestionFormat CEdit for Phone Number Pin
DanYELL9-Jul-09 12:04
DanYELL9-Jul-09 12:04 
AnswerRe: Format CEdit for Phone Number Pin
David Crow9-Jul-09 16:11
David Crow9-Jul-09 16:11 
GeneralRe: Format CEdit for Phone Number Pin
kilt9-Jul-09 23:25
kilt9-Jul-09 23:25 
GeneralRe: Format CEdit for Phone Number Pin
DanYELL10-Jul-09 1:46
DanYELL10-Jul-09 1:46 
QuestionRe: Format CEdit for Phone Number Pin
David Crow10-Jul-09 2:52
David Crow10-Jul-09 2:52 
AnswerRe: Format CEdit for Phone Number Pin
DanYELL10-Jul-09 3:28
DanYELL10-Jul-09 3:28 
GeneralRe: Format CEdit for Phone Number Pin
David Crow10-Jul-09 3:38
David Crow10-Jul-09 3:38 
QuestionLising Windows registred users Pin
RomTibi9-Jul-09 10:17
RomTibi9-Jul-09 10:17 
QuestionRe: Lising Windows registred users Pin
David Crow9-Jul-09 16:13
David Crow9-Jul-09 16:13 
AnswerRe: Lising Windows registred users Pin
RomTibi10-Jul-09 4:36
RomTibi10-Jul-09 4:36 
AnswerRe: Lising Windows registred users Pin
kilt9-Jul-09 23:24
kilt9-Jul-09 23:24 
GeneralRe: Lising Windows registred users Pin
RomTibi10-Jul-09 4:44
RomTibi10-Jul-09 4:44 
QuestionRe: Lising Windows registred users Pin
David Crow10-Jul-09 5:30
David Crow10-Jul-09 5:30 
AnswerRe: Lising Windows registred users Pin
RomTibi11-Jul-09 6:30
RomTibi11-Jul-09 6:30 
GeneralRe: Lising Windows registred users Pin
David Crow14-Sep-09 4:15
David Crow14-Sep-09 4:15 
GeneralRe: Lising Windows registred users Pin
kilt15-Jul-09 6:26
kilt15-Jul-09 6:26 

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.