http://www.commfort.com/tmp/plugin_read_board_post.rar
написан в BCB 2009
кому нужно, могу выложить полное считывание всех разделов, но только в MVS C++ 2010
Код: Выделить всё
void ReadParts(){
BYTE* buf;
DWORD size;
string BotName = TextToString(BOTNAME);//здесь преобразуется имя виртуального пользователя из wstring в string
size = CommFortGetData(dwPluginID, 1070, NULL, NULL, (BYTE*)BotName.c_str(), BotName.length());
buf = new BYTE[size];
CommFortGetData(dwPluginID, 1070, buf, size, (BYTE*)BotName.c_str(), BotName.length());
int count;
memcpy(&count, buf, 4);
buf += 4;
for (int i = 0; i < count; i++){
int ID;
memcpy(&ID, buf, 4);
buf += 4;
memcpy(&size, buf, 4);
buf += 4;
wstring Name;
Name.resize(size);
memcpy((void*)Name.c_str(), buf, size * 2);
buf += size * 2;
memcpy(&size, buf, 4);
buf += 4;
wstring Description;
Description.resize(size);
memcpy((void*)Description.c_str(), buf, size * 2);
buf += size * 2;
ReadAdvertsFromPart(ID);//считать все объявления выбранно раздела ДО
}
delete[] buf;
}
void ReadAdvertsFromPart(int PartID){
BYTE* buf;
DWORD size;
string Data = IntegerToString(PartID);
size = CommFortGetData(dwPluginID, 1071, NULL, NULL, (BYTE*)Data.c_str(), Data.length());
buf = new BYTE[size];
CommFortGetData(dwPluginID, 1071, buf, size, (BYTE*)Data.c_str(), Data.length());
int count;
memcpy(&count, buf, 4);//число(количество)
buf += 4;
for (int i = 0; i < count; i++){
int ID;
memcpy(&ID, buf, 4);//(число(ID объявления)
buf += 4;
double DateTime;
memcpy(&DateTime, buf, 8);//дата_и_время(публикации объявления)
buf += 8;
memcpy(&size, buf, 4);
buf += 4;
wstring AuthorName;
AuthorName.resize(size);
memcpy((void*)AuthorName.c_str(), buf, size * 2);//текст(имя автора)
buf += size * 2;
memcpy(&size, buf, 4);
buf += 4;
wstring Title;
Title.resize(size);
memcpy((void*)Title.c_str(), buf, size * 2);//текст(заголовок объявления)
buf += size * 2;
int CountComments;
memcpy(&CountComments, buf, 4);//число(количество комментариев)
buf += 4;
ReadSingleAdvert(ID);
}
}
void ReadSingleAdvert(int ID){
BYTE* buf;
DWORD size;
string Data = IntegerToString(ID); //ID объявления
size = CommFortGetData(dwPluginID, 1072, NULL , NULL, (BYTE*)Data.c_str(), aInBuffer.length());
buf = new BYTE[size];
CommFortGetData(dwPluginID, 1072, buf, size, (BYTE*)Data.c_str(), aInBuffer.length());
double DateTime;
memcpy(&DateTime, buf, 8);
buf += 8;
double Expired;
memcpy(&Expired, buf, 8);
buf += 8;
memcpy(&size, buf, 4);
buf += 4;
wstring AuthorName;
AuthorName.resize(size);
memcpy((void*)AuthorName.c_str(), buf, size * 2);
buf += size * 2;
memcpy(&size, buf, 4);
buf += 4;
wstring Header;
Header.resize(size);
memcpy((void*)Header.c_str(), buf, size * 2);
buf += size * 2;
memcpy(&size, buf, 4);
buf += 4;
wstring Text;
Text.resize(size);
memcpy((void*)Text.c_str(), buf, size * 2);
buf += size * 2;
memcpy(&size, buf, 4);
buf += 4;
wstring Question;
Question.resize(size);
memcpy((void*)Question.c_str(), buf, size * 2);
buf += size * 2;
int iAnswersCount;
memcpy(&iAnswersCount, buf, 4);
if (iAnswersCount > 0){
buf += 4;
for(int j = 0; j < iAnswersCount; j++){
wstring AnswerText;
memcpy(&size, buf, 4);
buf += 4;
AnswerText.resize(size);
memcpy((void*)AnswerText.c_str(), buf, size * 2);
buf += size * 2;
int VotesCount;// = fReadInteger(buf, &i);
memcpy(&VotesCount, buf, 4);
buf += 4;
}
}
int CommentsCount;
memcpy(&CommentsCount, buf, 4);
if (CommentsCount > 0){
buf += 4;
for (int j = 0; j < CommentsCount; j++){
int CommentID;
memcpy(&CommentID, buf, 4);
buf += 4;
double CommentDateTime;
memcpy(&CommentDateTime, buf, 8);
buf += 8;
wstring CommentAuthor;
memcpy(&size, buf, 4);
buf += 4;
CommentAuthor.resize(size);
memcpy((void*)CommentAuthor.c_str(), buf, size * 2);
buf += size * 2;
memcpy(&size, buf, 4);
buf += 4;
wstring CommentText;
Comment.resize(size);
memcpy((void*)Comment.c_str(), buf, size * 2);
buf += size * 2;
}
}
delete[] buf;
}
string TextToString(wstring Text){
int Length = Text.length();
string Return;
Return.resize(4 + Length * 2);
memcpy((void*)Return.c_str(), &Length, 4);
memcpy((void*)(Return.c_str() + 4), Text.c_str(), Length * 2);
return Return;
}
string IntegerToString(int Value){
string Return;
Return.resize(4);
memcpy((void*)Return.c_str(), &Value, 4);
return Return;
}