NntpGetFirstArticle
BOOL NntpGetFirstArticle(
HCLIENT hClient,  
LPNEWSARTICLE lpArticle  
);

The NntpGetFirstArticle function returns information about the first article in the currently selected newsgroup.

Parameters

hClient
Handle to the client session.
lpArticle
A pointer to a NEWSARTICLE structure which will contain information about the first article in the currently selected directory.

Return Value

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

Remarks

The NntpGetFirstArticle function returns information about the first article in the currently selected newsgroup. This function is used in conjunction with the NntpGetNextArticle function 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 NntpGetArticle function cannot be called while inside a loop calling NntpGetNextArticle. 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.

Example

NEWSARTICLE newsArticle;
BOOL bResult;
INT nResult;

// List all articles in the current group
nResult = NntpListArticles(hClient, -1L, -1L);

if (nResult == NNTP_ERROR)
{
    TCHAR szError[ASTRING];
    DWORD dwError = NntpGetLastError();
    NntpGetErrorString(dwError, szError, ASTRING);
    fprintf(stderr, "Error %08x: %s\n", dwError, szError);
    return;
}

// Get each article in the current newsgroup, printing the article
// number and the subject of the article
bResult = NntpGetFirstArticle(hClient, &newsArticle);
while (bResult)
{
    printf("%ld %s %s\n", newsArticle.nArticleId, newsArticle.szSubject);
    bResult = NntpGetNextArticle(hClient, &newsArticle);
}

Requirements

Client: Requires Windows Vista, Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or Windows 2000 Server.
Header: Include cstools6.h.
Library: Use csnwsav6.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

NntpGetArticle, NntpGetFirstGroup, NntpGetNextArticle, NntpGetNextGroup, NntpListArticles, NntpListGroups, NntpListNewGroups, NntpSelectGroup, NEWSARTICLE, NEWSGROUP


Copyright © 2008 Catalyst Development Corporation. All rights reserved.