Leaked source code of windows server 2003
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.

135 lines
4.2 KiB

  1. #if 0
  2. //---------------------------------------------------------------------------------------
  3. // ZoneToString
  4. //---------------------------------------------------------------------------------------
  5. HRESULT ZoneToString(DWORD dwZone, CString & sZone)
  6. {
  7. HRESULT hr = S_OK;
  8. switch(dwZone)
  9. {
  10. case 0:
  11. hr = sZone.Assign(L"MyComputer");
  12. break;
  13. case 1:
  14. hr = sZone.Assign(L"Intranet");
  15. break;
  16. case 2:
  17. hr = sZone.Assign(L"Trusted");
  18. break;
  19. case 3:
  20. hr = sZone.Assign(L"Internet");
  21. break;
  22. case 4:
  23. default:
  24. hr = sZone.Assign(L"Untrusted");
  25. break;
  26. }
  27. return hr;
  28. }
  29. #endif
  30. // handle for fnsshell.dll, saved in shelldll.cpp
  31. extern HINSTANCE g_DllInstance;
  32. //---------------------------------------------------------------------------------------
  33. // MakeCommandLine
  34. //---------------------------------------------------------------------------------------
  35. HRESULT MakeCommandLine(LPWSTR pwzManifestPath,
  36. LPWSTR pwzCodebase, CString &sHostPath, CString &sCommandLine)
  37. {
  38. HRESULT hr = S_OK;
  39. MAKE_ERROR_MACROS_STATIC(hr);
  40. LPWSTR pwzClickOncePath = NULL;
  41. CString sCodebase;
  42. IF_ALLOC_FAILED_EXIT(pwzClickOncePath = new WCHAR[MAX_PATH]);
  43. IF_WIN32_FALSE_EXIT(GetModuleFileName(g_DllInstance, pwzClickOncePath, MAX_PATH));
  44. #if 0
  45. IF_FAILED_EXIT(ZoneToString(dwZone, sZone));
  46. #endif
  47. if (pwzCodebase != NULL)
  48. {
  49. IF_FAILED_EXIT(sCodebase.Assign(pwzCodebase));
  50. IF_FAILED_EXIT(sCodebase.RemoveLastElement());
  51. IF_FAILED_EXIT(sCodebase.Append(L"/"));
  52. }
  53. else
  54. {
  55. //run from source
  56. IF_FAILED_EXIT(sCodebase.Assign(L"file://"));
  57. IF_FAILED_EXIT(sCodebase.Append(pwzManifestPath));
  58. IF_FAILED_EXIT(sCodebase.RemoveLastElement());
  59. IF_FAILED_EXIT(sCodebase.Append(L"/"));
  60. }
  61. IF_FAILED_EXIT(sHostPath.TakeOwnership(pwzClickOncePath, 0));
  62. pwzClickOncePath = NULL;
  63. IF_FAILED_EXIT(sHostPath.RemoveLastElement());
  64. IF_FAILED_EXIT(sHostPath.Append(L"\\ndphost.exe"));
  65. // NDP doesn't like a commandline without the path to exe
  66. IF_FAILED_EXIT(sCommandLine.Assign(L"\""));
  67. IF_FAILED_EXIT(sCommandLine.Append(sHostPath));
  68. IF_FAILED_EXIT(sCommandLine.Append(L"\" "));
  69. #if 0
  70. // NTRAID#NTBUG9-588432-2002/03/27-felixybc validate codebase, asmname, asm class, method, args
  71. // - asm names can have spaces,quotes?
  72. IF_FAILED_EXIT(sCommandLine.Append(L"-appbase: \""));
  73. IF_FAILED_EXIT(sCommandLine.Append(pwzAppRootDir));
  74. IF_FAILED_EXIT(sCommandLine.Append(L"\" -zone: "));
  75. IF_FAILED_EXIT(sCommandLine.Append(sZone));
  76. IF_FAILED_EXIT(sCommandLine.Append(L" -url: \""));
  77. IF_FAILED_EXIT(sCommandLine.Append(sCodebase));
  78. IF_FAILED_EXIT(sCommandLine.Append(L"\" -asmname: \""));
  79. IF_FAILED_EXIT(sCommandLine.Append(pwzAsmName));
  80. IF_FAILED_EXIT(sCommandLine.Append(L"\" "));
  81. if(pwzAsmClass)
  82. {
  83. IF_FAILED_EXIT(sCommandLine.Append(L" -class: "));
  84. IF_FAILED_EXIT(sCommandLine.Append(pwzAsmClass));
  85. if(pwzAsmMethod)
  86. {
  87. IF_FAILED_EXIT(sCommandLine.Append(L" -method: "));
  88. IF_FAILED_EXIT(sCommandLine.Append(pwzAsmMethod));
  89. if(pwzAsmArgs)
  90. {
  91. IF_FAILED_EXIT(sCommandLine.Append(L" -args: \""));
  92. IF_FAILED_EXIT(sCommandLine.Append(pwzAsmArgs));
  93. IF_FAILED_EXIT(sCommandLine.Append(L"\" "));
  94. }
  95. }
  96. }
  97. #endif
  98. IF_FAILED_EXIT(sCommandLine.Append(L"\"file://"));
  99. IF_FAILED_EXIT(sCommandLine.Append(pwzManifestPath));
  100. IF_FAILED_EXIT(sCommandLine.Append(L"\" \""));
  101. IF_FAILED_EXIT(sCommandLine.Append(sCodebase));
  102. IF_FAILED_EXIT(sCommandLine.Append(L"\""));
  103. LPWSTR ptr = sCommandLine._pwz;
  104. // bugbug - need to ensure no \" at end of command line or else thinks its a literal quote.
  105. // and fix this for only filepath
  106. while (*ptr)
  107. {
  108. if (*ptr == L'\\')
  109. *ptr = L'/';
  110. ptr++;
  111. }
  112. exit:
  113. SAFEDELETEARRAY(pwzClickOncePath);
  114. return hr;
  115. }