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.

172 lines
4.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. break;
  37. case DLL_PROCESS_DETACH:
  38. FreeMem(UpgradeData.pszProductId);
  39. FreeMem(UpgradeData.pszSourceA);
  40. FreeMem(UpgradeData.pszSourceW);
  41. FreeMem(UpgradeData.pszDir);
  42. FreeMem(pszNetPrnEntry);
  43. break;
  44. default:
  45. return FALSE;
  46. }
  47. return TRUE;
  48. }
  49. LONG
  50. QueryVersion(
  51. OUT LPCSTR *pszProductID,
  52. OUT LPUINT plDllVersion,
  53. OUT LPINT *pCodePageArray OPTIONAL,
  54. OUT LPCSTR *ExeNamesBuf OPTIONAL,
  55. OUT PVENDORINFO *pVendorInfo
  56. )
  57. {
  58. BOOL bFail = TRUE;
  59. DWORD dwRet, dwNeeded, dwReturned, dwLangId;
  60. if ( !(UpgradeData.pszProductId = GetStringFromRcFileA(IDS_PRODUCTID)) )
  61. goto Done;
  62. ZeroMemory(&VendorInfo, sizeof(VendorInfo));
  63. dwLangId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
  64. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  65. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  66. (LPVOID)UpgradeData.hInst,
  67. MSG_VI_COMPANY_NAME,
  68. dwLangId,
  69. VendorInfo.CompanyName,
  70. sizeof(VendorInfo.CompanyName),
  71. 0);
  72. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  73. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  74. (LPVOID)UpgradeData.hInst,
  75. MSG_VI_SUPPORT_NUMBER,
  76. dwLangId,
  77. VendorInfo.SupportNumber,
  78. sizeof(VendorInfo.SupportNumber),
  79. 0);
  80. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  81. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  82. (LPVOID)UpgradeData.hInst,
  83. MSG_VI_SUPPORT_URL,
  84. dwLangId,
  85. VendorInfo.SupportUrl,
  86. sizeof(VendorInfo.SupportUrl),
  87. 0);
  88. FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
  89. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  90. (LPVOID)UpgradeData.hInst,
  91. MSG_VI_INSTRUCTIONS,
  92. dwLangId,
  93. VendorInfo.InstructionsToUser,
  94. sizeof(VendorInfo.InstructionsToUser),
  95. 0);
  96. *pszProductID = UpgradeData.pszProductId;
  97. *plDllVersion = 1;
  98. *pCodePageArray = NULL;
  99. *ExeNamesBuf = NULL;
  100. *pVendorInfo = &VendorInfo;
  101. //
  102. // Call this DLL only if there are some printers or printer drivers
  103. // installed
  104. //
  105. if ( EnumPrinterDriversA(NULL,
  106. NULL,
  107. 3,
  108. NULL,
  109. 0,
  110. &dwNeeded,
  111. &dwReturned) &&
  112. EnumPrintersA(PRINTER_ENUM_LOCAL,
  113. NULL,
  114. 2,
  115. NULL,
  116. 0,
  117. &dwNeeded,
  118. &dwReturned) ) {
  119. return ERROR_NOT_INSTALLED;
  120. }
  121. bFail = FALSE;
  122. Done:
  123. if ( bFail ) {
  124. if ( dwRet = GetLastError() )
  125. return dwRet;
  126. return STG_E_UNKNOWN;
  127. }
  128. return ERROR_SUCCESS;
  129. }
  130. P_QUERY_VERSION pQueryVersion = QueryVersion;