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.

121 lines
2.5 KiB

  1. //
  2. // TheApp.cpp
  3. //
  4. #include "stdafx.h"
  5. #include <stdarg.h>
  6. #include "TheApp.h"
  7. #include "Util.h"
  8. #include "NetConn.h"
  9. //#include "MySvrApi.h"
  10. #include "MyPrSht.h"
  11. #include "Sharing.h"
  12. #include "NetEnum.h"
  13. #include "netconn.h"
  14. #include "netapi.h"
  15. #include "comctlwrap.h"
  16. #include <shellapi.h> // SHellExecute
  17. //
  18. // Get rid of msvcrt dependency since msvcrt didn't ship on all downlevel platforms
  19. //
  20. extern "C" int __cdecl _purecall(void)
  21. {
  22. return 0;
  23. }
  24. extern "C" int __cdecl _except_handler3(void)
  25. {
  26. return 0;
  27. }
  28. // String data
  29. //
  30. // Global variables
  31. //
  32. CHomeNetWizardApp theApp;
  33. BOOL CHomeNetWizardApp::IsBiDiLocalized()
  34. {
  35. return m_bBiDiLocalizedApp;
  36. }
  37. int CHomeNetWizardApp::MessageBox(UINT nStringID, UINT uType)
  38. {
  39. TCHAR szMsg[1024];
  40. TCHAR szTitle[256];
  41. LoadString(nStringID, szMsg, _countof(szMsg));
  42. LoadString(IDS_APPTITLE, szTitle, _countof(szTitle));
  43. return ::MessageBox(NULL, szMsg, szTitle, uType);
  44. }
  45. LPTSTR __cdecl CHomeNetWizardApp::FormatStringAlloc(UINT nStringID, ...)
  46. {
  47. va_list argList;
  48. va_start(argList, nStringID);
  49. LPTSTR pszMsg = NULL;
  50. LPTSTR pszFormat = LoadStringAlloc(nStringID);
  51. if (pszFormat)
  52. {
  53. int cchNeeded = EstimateFormatLength(pszFormat, argList);
  54. pszMsg = (LPTSTR)malloc(cchNeeded * sizeof(TCHAR));
  55. if (pszMsg)
  56. {
  57. wvnsprintf(pszMsg, cchNeeded, pszFormat, argList);
  58. }
  59. free(pszFormat);
  60. }
  61. return pszMsg;
  62. }
  63. LPTSTR __cdecl CHomeNetWizardApp::FormatStringAlloc(LPCTSTR pszFormat, ...)
  64. {
  65. va_list argList;
  66. va_start(argList, pszFormat);
  67. int cchNeeded = EstimateFormatLength(pszFormat, argList);
  68. LPTSTR pszMsg = (LPTSTR)malloc(cchNeeded * sizeof(TCHAR));
  69. if (pszMsg)
  70. {
  71. wvnsprintf(pszMsg, cchNeeded, pszFormat, argList);
  72. }
  73. return pszMsg;
  74. }
  75. int __cdecl CHomeNetWizardApp::MessageBoxFormat(UINT uType, UINT nStringID, ...)
  76. {
  77. TCHAR szTitle[256];
  78. LoadString(IDS_APPTITLE, szTitle, _countof(szTitle));
  79. int nResult = 0;
  80. LPTSTR pszFormat = LoadStringAlloc(nStringID);
  81. if (pszFormat)
  82. {
  83. va_list argList;
  84. va_start(argList, nStringID);
  85. int cchNeeded = EstimateFormatLength(pszFormat, argList);
  86. LPTSTR pszMsg = (LPTSTR)malloc(cchNeeded * sizeof(TCHAR));
  87. if (pszMsg)
  88. {
  89. wvnsprintf(pszMsg, cchNeeded, pszFormat, argList);
  90. nResult = ::MessageBox(NULL, pszMsg, szTitle, uType);
  91. free(pszMsg);
  92. }
  93. free(pszFormat);
  94. }
  95. return nResult;
  96. }