NntpListGroups Function  
 
INT WINAPI NntpListGroups(
  HCLIENT hClient  
);

The NntpListGroups function instructs the server to begin sending a list of newsgroups back to the client.

Parameters

hClient
Handle to the client session.

Return Value

If the function succeeds, the return value is the server result code. If the function fails, the return value is NNTP_ERROR. To get extended error information, call NntpGetLastError.

Remarks

The NntpListGroups function is used in conjunction with the NntpGetFirstGroup and NntpGetNextGroup functions to enumerate all of the available newsgroups. Typically this is used to provide the user with a list of newsgroups to select. To list only those newsgroups which have been added since a certain date, use the NntpListNewGroups function.

While the newsgroups are being listed, the client cannot select a newsgroup or retrieve the contents of a specific article. The client should store those newsgroups which it wants to retrieve articles from, and then once all of the newsgroups have been listed, it can then select each newsgroup and retrieve the available articles from that group.

Example

NEWSGROUP newsGroup;
BOOL bResult;
INT nResult;

// List all available newsgroups
nResult = NntpListGroups(hClient);

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 newsgroup, printing the article range and
// the name of the group
bResult = NntpGetFirstGroup(hClient, &newsGroup);
while (bResult)
{
    printf("%ld %ld %s\n", newsGroup.nFirstArticle,
                           newsGroup.nLastArticle,
                           newsGroup.szName);
    bResult = NntpGetNextGroup(hClient, &newsGroup);
}

Requirements

Client: Requires Windows 7, Windows Vista or Windows XP.
Server: Requires Windows Server 2008 or Windows Server 2003.
Header: Include cstools7.h.
Library: Use csnwsav7.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

NntpGetArticleRange, NntpGetFirstGroup, NntpGetNextGroup, NntpListNewGroups, NntpSelectGroup