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.

177 lines
3.5 KiB

  1. /**************************************************/
  2. /* */
  3. /* */
  4. /* EudcEditor Utillity funcs */
  5. /* */
  6. /* */
  7. /* Copyright (c) 1997-1999 Microsoft Corporation. */
  8. /**************************************************/
  9. #include "stdafx.h"
  10. #include "eudcedit.h"
  11. #include "util.h"
  12. #define STRSAFE_LIB
  13. #include <strsafe.h>
  14. /****************************************/
  15. /* */
  16. /* Output Message function */
  17. /* */
  18. /****************************************/
  19. int
  20. OutputMessageBox(
  21. HWND hWnd,
  22. UINT TitleID,
  23. UINT MessgID,
  24. BOOL OkFlag)
  25. {
  26. CString TitleStr, MessgStr;
  27. int mResult;
  28. TitleStr.LoadString( TitleID);
  29. MessgStr.LoadString( MessgID);
  30. if( OkFlag){
  31. mResult = ::MessageBox( hWnd, MessgStr, TitleStr,
  32. MB_OK | MB_ICONEXCLAMATION);
  33. }else{
  34. mResult = ::MessageBox( hWnd, MessgStr, TitleStr,
  35. MB_YESNOCANCEL | MB_ICONQUESTION);
  36. }
  37. return mResult;
  38. }
  39. #ifdef BUILD_ON_WINNT
  40. int
  41. OutputMessageBoxEx(
  42. HWND hWnd,
  43. UINT TitleID,
  44. UINT MessgID,
  45. BOOL OkFlag,
  46. ...)
  47. {
  48. CString TitleStr, MessgStr;
  49. int mResult = 0;
  50. va_list argList;
  51. LPTSTR MessageBody;
  52. va_start(argList, OkFlag);
  53. TitleStr.LoadString( TitleID);
  54. MessgStr.LoadString( MessgID);
  55. ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_STRING,
  56. MessgStr,0,0,(LPTSTR)&MessageBody,0,&argList);
  57. if( MessageBody ) {
  58. if( OkFlag){
  59. mResult = ::MessageBox( hWnd, MessageBody, TitleStr,
  60. MB_OK | MB_ICONEXCLAMATION);
  61. }else{
  62. mResult = ::MessageBox( hWnd, MessageBody, TitleStr,
  63. MB_YESNOCANCEL | MB_ICONQUESTION);
  64. }
  65. ::LocalFree(MessageBody);
  66. }
  67. return mResult;
  68. }
  69. #endif // BUILD_ON_WINNT
  70. /****************************************/
  71. /* */
  72. /* Get String from resource */
  73. /* */
  74. /****************************************/
  75. void
  76. GetStringRes(
  77. LPTSTR lpStr,
  78. UINT sID,
  79. int nLength)
  80. {
  81. CString cStr;
  82. int StrLength;
  83. TCHAR *Swap;
  84. HRESULT hresult;
  85. if (!lpStr)
  86. {
  87. return;
  88. }
  89. cStr.LoadString( sID);
  90. StrLength = cStr.GetLength();
  91. Swap = cStr.GetBuffer(StrLength + 1);
  92. //*STRSAFE* lstrcpy( lpStr, Swap);
  93. hresult =StringCchCopy(lpStr , nLength, Swap);
  94. if (!SUCCEEDED(hresult))
  95. {
  96. }
  97. cStr.ReleaseBuffer();
  98. return;
  99. }
  100. /****************************************/
  101. /* */
  102. /* Convert String from resource */
  103. /* */
  104. /****************************************/
  105. void
  106. ConvStringRes(
  107. LPTSTR lpStr,
  108. CString String,
  109. int nDestSize
  110. )
  111. {
  112. TCHAR *Swap;
  113. HRESULT hresult;
  114. int StrLength = String.GetLength();
  115. Swap = String.GetBuffer(StrLength + 1);
  116. //*STRSAFE* lstrcpy( lpStr, Swap);
  117. hresult = StringCchCopy(lpStr , nDestSize, Swap);
  118. if (!SUCCEEDED(hresult))
  119. {
  120. }
  121. String.ReleaseBuffer();
  122. return;
  123. }
  124. #ifndef UNICODE
  125. char * Mystrrchr(char *pszString, char ch)
  126. {
  127. CHAR *p1, *p2;
  128. p1 = NULL;
  129. if (!pszString)
  130. {
  131. return (p1);
  132. }
  133. for (p2 = pszString; *p2; p2=CharNext(p2))
  134. {
  135. if (*p2 == ch)
  136. {
  137. p1 = p2;
  138. }
  139. }
  140. return (p1);
  141. }
  142. char * Mystrchr(char *pszString, char ch)
  143. {
  144. CHAR *p;
  145. if (!pszString)
  146. {
  147. return (NULL);
  148. }
  149. for (p = pszString; *p; p=CharNext(p))
  150. {
  151. if (*p == ch)
  152. {
  153. return (p);
  154. }
  155. }
  156. return (NULL);
  157. }
  158. #endif