How to get the utilization "the crossplatform way". This sample can be compiled into an NLM or a Win32 application.
#ifdef __MWERKS__
#pragma ANSI_strict off
#endif
#include <nwcalls.h>
#include <nwclxcon.h>
#ifdef __MWERKS__
#pragma ANSI_strict reset
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char* argv[]) {
char* server_name;
NWRCODE rcode;
NWCCODE ccode;
NWCONN_HANDLE conn_handle;
NWFSE_FILE_SERVER_INFO fs_info;
if ( argc != 2) {
printf( "Usage: %s <servername>\n", *argv);
return EXIT_FAILURE;
}
server_name = strupr( *++argv);
rcode = NWCCOpenConnByName( 0,
server_name,
NWCC_NAME_FORMAT_BIND,
NWCC_OPEN_LICENSED,
NWCC_TRAN_TYPE_WILD,
&conn_handle);
if ( rcode != 0) {
printf( "NWCCOpenConnByName failed, rcode = %x", rcode);
return EXIT_FAILURE;
}
ccode = NWGetFileServerInfo( conn_handle, &fs_info);
if ( ccode != 0) {
printf( "NWGetFileServerInfo failed, ccode = %x", ccode);
NWCCCloseConn( conn_handle);
return EXIT_FAILURE;
}
printf( "fs_info.serverUtilization = %u\n", fs_info.serverUtilization);
NWCCCloseConn( conn_handle);
return EXIT_SUCCESS;
}
© 2008 Novell, Inc. All Rights Reserved.