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.

197 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. Migmain.c
  6. Abstract:
  7. Routines to migrate Win95 to NT
  8. Author:
  9. Muhunthan Sivapragasam (MuhuntS) 02-Jan-1996
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. #include <devguid.h>
  15. #include "msg.h"
  16. VENDORINFO VendorInfo;
  17. UPGRADE_DATA UpgradeData;
  18. CHAR szNetprnFile[] = "netwkprn.txt";
  19. BOOL
  20. DllMain(
  21. IN HINSTANCE hInst,
  22. IN DWORD dwReason,
  23. IN LPVOID lpRes
  24. )
  25. /*++
  26. Routine Description:
  27. Dll entry point.
  28. Arguments:
  29. Return Value:
  30. --*/
  31. {
  32. UNREFERENCED_PARAMETER(lpRes);
  33. switch( dwReason ){
  34. case DLL_PROCESS_ATTACH:
  35. UpgradeData.hInst = hInst;
  36. UpgradeData.pszProductId = NULL;
  37. UpgradeData.pszSourceA = NULL;
  38. UpgradeData.pszSourceW = NULL;
  39. UpgradeData.pszDir = NULL;
  40. break;
  41. case DLL_PROCESS_DETACH:
  42. FreeMem(UpgradeData.pszProductId);
  43. FreeMem(UpgradeData.pszSourceA);
  44. FreeMem(UpgradeData.pszSourceW);
  45. FreeMem(UpgradeData.pszDir);
  46. FreeMem(pszNetPrnEntry);
  47. break;
  48. default:
  49. return FALSE;
  50. }
  51. return TRUE;
  52. }
  53. LONG
  54. QueryVersion(
  55. OUT LPCSTR *pszProductID,
  56. OUT LPUINT plDllVersion,
  57. OUT LPINT *pCodePageArray OPTIONAL,
  58. OUT LPCSTR *ExeNamesBuf OPTIONAL,
  59. OUT PVENDORINFO *pVendorInfo
  60. )
  61. {
  62. BOOL bFail = TRUE;
  63. DWORD dwRet, dwNeeded, dwReturned, dwLangId;
  64. if(!pszProductID || !plDllVersion || !pVendorInfo)
  65. {
  66. SetLastError(ERROR_INVALID_PARAMETER);
  67. return ERROR_INVALID_PARAMETER;
  68. }
  69. if ( !(UpgradeData.pszProductId = GetStringFromRcFileA(IDS_PRODUCTID)) )
  70. goto Done;
  71. ZeroMemory(&VendorInfo, sizeof(VendorInfo));
  72. dwLangId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
  73. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  74. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  75. (LPVOID)UpgradeData.hInst,
  76. MSG_VI_COMPANY_NAME,
  77. dwLangId,
  78. VendorInfo.CompanyName,
  79. sizeof(VendorInfo.CompanyName),
  80. 0);
  81. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  82. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  83. (LPVOID)UpgradeData.hInst,
  84. MSG_VI_SUPPORT_NUMBER,
  85. dwLangId,
  86. VendorInfo.SupportNumber,
  87. sizeof(VendorInfo.SupportNumber),
  88. 0);
  89. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  90. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  91. (LPVOID)UpgradeData.hInst,
  92. MSG_VI_SUPPORT_URL,
  93. dwLangId,
  94. VendorInfo.SupportUrl,
  95. sizeof(VendorInfo.SupportUrl),
  96. 0);
  97. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  98. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  99. (LPVOID)UpgradeData.hInst,
  100. MSG_VI_INSTRUCTIONS,
  101. dwLangId,
  102. VendorInfo.InstructionsToUser,
  103. sizeof(VendorInfo.InstructionsToUser),
  104. 0);
  105. //
  106. // Since we are not checking the return value from FormatMessage we null-terminate the strings
  107. // to make sure they are NULL-terminated.
  108. //
  109. VendorInfo.CompanyName[sizeof(VendorInfo.CompanyName)-1] = 0;
  110. VendorInfo.SupportNumber[sizeof(VendorInfo.SupportNumber)-1] = 0;
  111. VendorInfo.SupportUrl[sizeof(VendorInfo.SupportUrl)-1] = 0;
  112. VendorInfo.InstructionsToUser[sizeof(VendorInfo.InstructionsToUser)-1] = 0;
  113. *pszProductID = UpgradeData.pszProductId;
  114. *plDllVersion = 1;
  115. if(pCodePageArray)
  116. {
  117. *pCodePageArray = NULL;
  118. }
  119. if(ExeNamesBuf)
  120. {
  121. *ExeNamesBuf = NULL;
  122. }
  123. *pVendorInfo = &VendorInfo;
  124. //
  125. // Call this DLL only if there are some printers or printer drivers
  126. // installed
  127. //
  128. if ( EnumPrinterDriversA(NULL,
  129. NULL,
  130. 3,
  131. NULL,
  132. 0,
  133. &dwNeeded,
  134. &dwReturned) &&
  135. EnumPrintersA(PRINTER_ENUM_LOCAL,
  136. NULL,
  137. 2,
  138. NULL,
  139. 0,
  140. &dwNeeded,
  141. &dwReturned) ) {
  142. return ERROR_NOT_INSTALLED;
  143. }
  144. bFail = FALSE;
  145. Done:
  146. if ( bFail ) {
  147. if ( dwRet = GetLastError() )
  148. return dwRet;
  149. return STG_E_UNKNOWN;
  150. }
  151. return ERROR_SUCCESS;
  152. }
  153. P_QUERY_VERSION pQueryVersion = QueryVersion;