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.

73 lines
1.5 KiB

  1. // File: wb32stub.cpp
  2. #include <windows.h>
  3. #include <tchar.h>
  4. #include "SDKInternal.h"
  5. #ifdef _DEBUG
  6. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hInstPrev, LPTSTR lpCmdLine, int nCmdShow)
  7. {
  8. lpCmdLine = GetCommandLine();
  9. #else // _DEBUG
  10. int __cdecl main()
  11. {
  12. LPTSTR lpCmdLine = GetCommandLine();
  13. #endif // _DEBUG
  14. // All I have to do is find two quotes
  15. int nQuotes = 0;
  16. while((nQuotes != 2) && (*lpCmdLine))
  17. {
  18. if(*lpCmdLine == '"')
  19. {
  20. ++nQuotes;
  21. }
  22. lpCmdLine = CharNext(lpCmdLine);
  23. }
  24. // Skip the whitespace
  25. lpCmdLine = CharNext(lpCmdLine);
  26. CoInitialize(NULL);
  27. IInternalConfExe* pConf = NULL;
  28. if(SUCCEEDED(CoCreateInstance(CLSID_NmManager, NULL, CLSCTX_LOCAL_SERVER, IID_IInternalConfExe, reinterpret_cast<void**>(&pConf))))
  29. {
  30. BSTR strCmdLine = NULL;
  31. bool bOldWB = true;
  32. if(*lpCmdLine)
  33. {
  34. if(('-' == lpCmdLine[0]) && (' ' == lpCmdLine[1]))
  35. {
  36. bOldWB = false;
  37. lpCmdLine = CharNext(lpCmdLine);
  38. lpCmdLine = CharNext(lpCmdLine);
  39. }
  40. int nConvertedLen = MultiByteToWideChar(CP_ACP, 0, lpCmdLine, -1, NULL, NULL) - 1;
  41. strCmdLine = ::SysAllocStringLen(NULL, nConvertedLen);
  42. if(strCmdLine != NULL)
  43. {
  44. MultiByteToWideChar(CP_ACP, 0, lpCmdLine, -1, strCmdLine, nConvertedLen);
  45. }
  46. }
  47. pConf->LaunchApplet(bOldWB ? NM_APPID_WHITEBOARD : NM_APPID_T126_WHITEBOARD, strCmdLine);
  48. pConf->Release();
  49. if(strCmdLine)
  50. {
  51. SysFreeString(strCmdLine);
  52. }
  53. }
  54. CoUninitialize();
  55. #ifndef _DEBUG
  56. ExitProcess(0);
  57. #endif
  58. return 0;
  59. }