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.

132 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. kill.c
  5. Abstract:
  6. This module implements a task killer application.
  7. Author:
  8. Wesley Witt (wesw) 20-May-1994
  9. Environment:
  10. User Mode
  11. --*/
  12. #include <windows.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <tchar.h>
  16. #include "common.h"
  17. VOID
  18. Usage(
  19. VOID
  20. );
  21. DWORD NumberOfArguments;
  22. PWSTR Arguments[ 128 ];
  23. int _cdecl
  24. main(
  25. int argc,
  26. char *argv[]
  27. )
  28. {
  29. PWSTR s, *pArgs;
  30. BOOLEAN IsMountPoint = FALSE;
  31. PWSTR LinkName, TargetPath;
  32. WCHAR TargetPathBuffer[ MAX_PATH ];
  33. GetCommandLineArgs( &NumberOfArguments, Arguments );
  34. if (NumberOfArguments == 0) {
  35. Usage();
  36. return 1;
  37. }
  38. pArgs = &Arguments[ 0 ];
  39. s = *pArgs;
  40. if (s && (*s == L'-' || *s == L'/')) {
  41. _tcslwr( ++s );
  42. if (*s == L'm') {
  43. IsMountPoint = TRUE;
  44. NumberOfArguments -= 1;
  45. s = *++pArgs;
  46. }
  47. else
  48. if (*s == L'?') {
  49. Usage();
  50. return 0;
  51. }
  52. else {
  53. Usage();
  54. return 1;
  55. }
  56. }
  57. if (NumberOfArguments > 2) {
  58. Usage();
  59. return 1;
  60. }
  61. LinkName = s;
  62. if (NumberOfArguments == 2) {
  63. TargetPath = *++pArgs;
  64. CreateSymbolicLinkW( LinkName, TargetPath, IsMountPoint, NULL );
  65. }
  66. else {
  67. QuerySymbolicLinkW( LinkName, TargetPathBuffer, MAX_PATH );
  68. }
  69. return 0;
  70. }
  71. VOID
  72. Usage(
  73. VOID
  74. )
  75. /*++
  76. Routine Description:
  77. Prints usage text for this tool.
  78. Arguments:
  79. None.
  80. Return Value:
  81. None.
  82. --*/
  83. {
  84. fprintf( stderr, "Microsoft (R) Windows NT (TM) Version 5.0 MKLNK\n" );
  85. fprintf( stderr, "Copyright (C) 1997 Microsoft Corp. All rights reserved\n\n" );
  86. fprintf( stderr, "usage: SYMLINK [-m] fileName [targetPath]\n\n" );
  87. fprintf( stderr, " -m specifies to create a mount point link\n" );
  88. fprintf( stderr, " instead of a symbolic link\n\n" );
  89. fprintf( stderr, " fileName\n" );
  90. fprintf( stderr, " This is the name of the symbolic link\n" );
  91. fprintf( stderr, " to be created, modified or queried.\n" );
  92. fprintf( stderr, " \n" );
  93. fprintf( stderr, " targetPath\n" );
  94. fprintf( stderr, " If not specified, this program displays\n" );
  95. fprintf( stderr, " the current targetPath associated with \n" );
  96. fprintf( stderr, " the named symbolic link.\n" );
  97. fprintf( stderr, " If specified, either creates a new symbolic\n" );
  98. fprintf( stderr, " link that points to this targetPath\n" );
  99. fprintf( stderr, " or if the named symbolic link already exists,\n" );
  100. fprintf( stderr, " modifies its targetPath to the new value.\n" );
  101. ExitProcess(0);
  102. }