Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.9 KiB

  1. /***
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. SetShare.c
  5. Abstract:
  6. This is a command line test utility for setting the
  7. shareable bit on a file on a Netware server.
  8. Author:
  9. Cory West [corywest] 25-April-96
  10. ***/
  11. #include "ndsapi32.h"
  12. int
  13. _cdecl main(
  14. int argc,
  15. char **argv
  16. ) {
  17. NTSTATUS Status;
  18. int ReturnCode = 0;
  19. IO_STATUS_BLOCK IoStatusBlock;
  20. HANDLE hFile;
  21. //
  22. // Check the command line arguments for a file.
  23. //
  24. if ( argc < 1 ) {
  25. printf( "Usage: setshare [path to file]\n" );
  26. return -1;
  27. }
  28. //
  29. // Open the file.
  30. //
  31. hFile = CreateFile( argv[1], // file name
  32. GENERIC_READ, // read access
  33. 0, // exclusive
  34. NULL, // no security specifications
  35. OPEN_EXISTING, // do not create
  36. 0, // no attributes that we care about
  37. NULL ); // no template
  38. if ( hFile == INVALID_HANDLE_VALUE ) {
  39. printf( "Couldn't open the request file. Error = %08lx\n", Status );
  40. return -1;
  41. }
  42. //
  43. // Tell the redirector to set the shareable bit.
  44. //
  45. Status = NtFsControlFile( hFile,
  46. NULL,
  47. NULL,
  48. NULL,
  49. &IoStatusBlock,
  50. FSCTL_NWR_SET_SHAREBIT,
  51. NULL,
  52. 0,
  53. NULL,
  54. 0 );
  55. if ( !NT_SUCCESS( Status ) ) {
  56. printf( "A parameter was not correct. This only works for a file\n" );
  57. printf( "on a Netware volume. Status = %08lx\n", Status );
  58. ReturnCode = -1;
  59. }
  60. CloseHandle( hFile );
  61. //
  62. // The bit actually gets set when you close the file.
  63. //
  64. return ReturnCode;
  65. }