#include <stdio.h>
#include <windows.h>
#include <lm.h>
#pragma hdrstop



int main( void );



int main( void )
{
	//*********************************	change these:
	wchar_t *pServer = L"\\\\BAR";		// server to run on
	wchar_t *pShare  = L"CD";			// sharename to query
	//*********************************

	NET_API_STATUS rc; // result code
	SHARE_INFO_2 *pSI;
	const char *sharetype;
	byte *pBuf;

	pBuf = NULL;

	// note -- LPTSTR cast needed because of bogus header files
	rc = NetShareGetInfo( (LPTSTR) pServer, (LPTSTR) pShare, 2, &pBuf );

	if ( ( rc == NERR_Success || rc == ERROR_MORE_DATA ) && pBuf != NULL )
	{
		pSI = (SHARE_INFO_2 *) pBuf;
		switch ( pSI->shi2_type )
		{
		case STYPE_DISKTREE:
			sharetype = "disk";
			break;
		case STYPE_PRINTQ:
			sharetype = "print queue";
			break;
		case STYPE_DEVICE:
			sharetype = "comms queue";
			break;
		case STYPE_IPC:
			sharetype = "IPC";
			break;
		default:
			sharetype = "unknown";
			break;
		}
		printf( "Netname: %S\n", pSI->shi2_netname );
		printf( "Type:    %s\n", sharetype );
		printf( "Remark:  %S\n", pSI->shi2_remark );
		if ( pSI->shi2_max_uses == (DWORD) (-1L) )
			printf( "Max use: unlimited\n" );
		else
			printf( "Max use: %lu\n", pSI->shi2_max_uses );
		printf( "Cur use: %lu\n", pSI->shi2_current_uses );
		printf( "Path:    %S\n", pSI->shi2_path );
	}

	if ( pBuf != NULL )
		NetApiBufferFree( pBuf );

	if ( rc != NERR_Success )
		printf( "Oops! Error %lu encountered!\n", rc );

	return 0;
}


