#include <ncpext.h>int NWScanNCPExtensions( LONG
NCPExtensionID, char
NCPExtensionName, BYTE
majorVersion, BYTE
minorVersion, BYTE
revision, void
queryData);
#include <nwncpext.h> or #include <nwcalls.h>
NWCCODE N_API NWScanNCPExtensions( NWCONN_HANDLE conn, pnuint32 NCPExtensionID, pnstr8 NCPExtensionName, pnuint8 majorVersion, pnuint8 minorVersion, pnuint8 revision, pnuint8 queryData);
The parameters are as follows:
0 | (0x00) | SUCCESSFUL | NCP Extension information was returned, and all non-NULL output parameters are filled. |
1-16 | - | - | An NCP error occurred; see <niterror.h>. |
255 | (0xFF) | ERR_NO_ITEMS_FOUND | No more NCP Extensions were found. |
NWScanNCPExtensions can be used iteratively to return the names of all the NCP Extensions registered on the server being queried. To scan the complete list of NCP Extensions, start with NCPExtensionID set to BEGIN_SCAN_NCP_EXTENSIONS. When NWScanNCPExtensions returns, NCPExtensionID is set to the ID of the first NCP Extension in the list, and the return value is SUCCESSFUL. Then use the ID in NCPExtensionID as a seed value to find the next NCP Extension ID. Continue calling NWScanNCPExtensions, using the new IDs returned in NCPExtensionID, until you find the information you want or until ERR_NO_ITEMS_FOUND is returned as shown in the example for NWScanNCPExtensions.
Note that the IDs of NCP Extensions are not always consecutive numbers. Therefore, you should not assume that if you increment the value in NCPExtensionID by one that it is a valid NCP Extension ID.
NWScanNCPExtensions is most likely to be used when you want to list the names of the NCP Extensions but are not looking for the name of a specific extension. If you know the name of your NCP Extension, such as ``My NCP Extension,'' you should call NWGetNCPExtensionInfo (NLM) to see if the extension is registered, because NWGetNCPExtensionInfo needs to be called only once.
Like NWGetNCPExtensionInfo, you can call NWScanNCPExtensions to do the following:
The fields majorVersion, minorVersion, and revision are assigned by the registering NLM when it calls NWRegisterNCPExtension. If you are going to have different versions or revisions of the NCP Extension, the client can use these fields to verify that the extension is of the correct version. If you do not want to use this information, you can pass NULL in these parameters.
In some cases NWScanNCPExtensionInfo can return all of the information you need, eliminating the need to call NWSendNCPExtensionRequest. This is accomplished through the queryData pointer which is set to point to the buffer (32 bytes or less) allocated when the NLM calls NWRegisterNCPExtension. If all the information you want can be returned in this buffer, you can simplify the service by obtaining the buffer contents with NWGetNCPExtensionInfo (NLM). (Receiving information in this manner does not call the NCP Extension handler.) This method is useful only if a one-way server-to-client message is sufficient.
If you do not need the information that is returned in the buffer, you can pass NULL for this parameter.
#include <stdio.h> #include <ncpext.h> #include <niterror.h>main() { BYTE majorVersion, minorVersion, revision; char NCPExtensionName[33]; int cCode; LONG NCPExtensionID; NCPExtensionID = BEGIN_SCAN_NCP_EXTENSIONS /* -1 */
do{ cCode = NWScanNCPExtensions(&NCPExtensionID,NCPExtensioName, &majorVersion,\ &minorVersion, &revision, NULL); if(cCode == 0) { printf(``\nExtension Name = %s, Extension ID = %d'',NCPExtensionName,\ NCPExtensionID); printf(``\nMajor Version = %d, Minor Version = %d, Revision = %d'',\ majorVersion, minorVersion, revision); } } while(cCode != ERR_NO_ITEMS_FOUND); }