CNntpClient::GetFirstArticle Method  
 
BOOL GetFirstArticle(
  LPNEWSARTICLE lpArticle  
);
BOOL GetFirstArticle(
  LPNEWSARTICLEEX lpArticle  
);

The GetFirstArticle method returns information about the first article in the currently selected newsgroup.

Parameters

lpArticle
A pointer to a NEWSARTICLE or NEWSARTICLEEX structure which will contain information about the first article in the currently selected directory. If the server can potentially return very large article IDs, it is recommended that you use the NEWSARTICLEEX structure.

Return Value

If the method succeeds, the return value is non-zero. If there are no articles in the current newsgroup, or the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The GetFirstArticle method returns information about the first article in the currently selected newsgroup. This method is used in conjunction with the GetNextArticle method to enumerate all of the articles in the newsgroup. Typically this is used to provide the user with a list of articles to access.

While the articles in the newsgroup are being listed, the client cannot retrieve the contents of a specific article. For example, the GetArticle method cannot be called while inside a loop calling GetNextArticle. The client should store those articles which it wants to retrieve in an array, and then once all of the articles have been listed, it can begin calling NttpGetArticle for each article number to retrieve the article text.

The date and time that the article was posted is returned in the stPosted member of the NEWSARTICLE structure. This value is returned in Universal Coordinated Time (UTC) and can be converted to local time using the SystemTimeToTzSpecificLocalTime function.

Example

// List all articles in the current group
if (pClient->ListArticles() == NNTP_ERROR)
    pClient->ShowError();
else
{
    NEWSARTICLE newsArticle;
    BOOL bResult;

    // Get each article in the current newsgroup, printing the article
    // number and the subject of the article
    bResult = pClient->GetFirstArticle(&newsArticle);
    while (bResult)
    {
        _tprintf(_T("%ld %s\n"), newsArticle.nArticleId, newsArticle.szSubject);
        bResult = pClient->GetNextArticle(&newsArticle);
    }
}

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csnwsv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

GetArticle, GetFirstGroup, GetNextArticle, GetNextGroup, ListArticles, ListGroups, SelectGroup, NEWSARTICLE, NEWSGROUP