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.

339 lines
8.6 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: sti_ci.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: KeisukeT
  10. *
  11. * DATE: 27 Mar, 2000
  12. *
  13. * DESCRIPTION:
  14. * Generic header file for WIA class installer.
  15. *
  16. *******************************************************************************/
  17. #ifndef _STI_CI_H_
  18. #define _STI_CI_H_
  19. //
  20. // Include
  21. //
  22. #include <windows.h>
  23. #include <windowsx.h>
  24. #include <assert.h>
  25. #include <tchar.h>
  26. #include <setupapi.h>
  27. #include "resource.h"
  28. #include "cistr.h"
  29. #include "debug.h"
  30. //
  31. // Define
  32. //
  33. #define ID_AUTO -1
  34. #define NUM_WIA_PAGES 5
  35. #define MAX_DATA_SECTION 512*sizeof(TCHAR)
  36. #define MAX_DESCRIPTION 64*sizeof(TCHAR)
  37. #define MAX_FRIENDLYNAME 64
  38. #define MAX_DEVICE_ID 64
  39. #define MAX_COMMANDLINE 256
  40. #define MAX_STRING_LENGTH 1024
  41. #define MAX_MUTEXTIMEOUT 60*1000 // 60 Sec
  42. #define MANUAL_INSTALL_MASK 100
  43. #define INVALID_DEVICE_INDEX -1
  44. #define MONITOR_NAME TEXT("STIMON.EXE")
  45. #define RUNDLL32 TEXT("RUNDLL32.EXE")
  46. #define STILL_IMAGE TEXT("StillImage")
  47. #define FRIENDLYNAME TEXT("FriendlyName")
  48. #define VENDORSETUP TEXT("VendorSetup")
  49. #define DEVICESECTION TEXT("DeviceData")
  50. #define PORTNAME TEXT("PortName")
  51. #define DEVICETYPE TEXT("DeviceType")
  52. #define DEVICESUBTYPE TEXT("DeviceSubType")
  53. #define DRIVERDESC TEXT("DriverDesc")
  54. #define DESCRIPTION TEXT("Description")
  55. #define CREATEFILENAME TEXT("CreateFileName")
  56. #define CAPABILITIES TEXT("Capabilities")
  57. #define EVENTS TEXT("Events")
  58. #define WIASECTION TEXT("WiaSection")
  59. #define PROPERTYPAGES TEXT("PropertyPages")
  60. #define VENDOR TEXT("Vendor")
  61. #define UNINSTALLSECTION TEXT("UninstallSection")
  62. #define SUBCLASS TEXT("SubClass")
  63. #define ICMPROFILES TEXT("ICMProfiles")
  64. #define INFPATH TEXT("InfPath")
  65. #define INFSECTION TEXT("InfSection")
  66. #define ISPNP TEXT("IsPnP")
  67. #define USDCLASS TEXT("USDClass")
  68. #define LPTENUM TEXT("LptEnum")
  69. #define ENUM TEXT("\\Enum")
  70. #define PORTS TEXT("Ports")
  71. #define DONT_LOAD TEXT("don't load")
  72. #define CONTROL_INI TEXT("control.ini")
  73. #define CPL_NAME TEXT("sticpl.cpl")
  74. #define NO TEXT("no")
  75. #define LAUNCH_APP TEXT("LaunchApplications")
  76. #define SZ_GUID TEXT("GUID")
  77. #define CONNECTION TEXT("Connection")
  78. #define SERIAL TEXT("Serial")
  79. #define PARALLEL TEXT("Parallel")
  80. #define BOTH TEXT("Both")
  81. #define AUTO TEXT("AUTO")
  82. #define VIDEO_PATH_ID TEXT("DShowDeviceId")
  83. #define DEVICESECTION TEXT("DeviceData")
  84. #define WIAACMGR_PATH TEXT("wiaacmgr.exe")
  85. #define WIAACMGR_ARG TEXT("-SelectDevice")
  86. #define WIADEVLISTMUTEX TEXT("WiaDeviceListMutex")
  87. #define WIA_GUIDSTRING TEXT("{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}")
  88. #define STI_CI32_ENTRY_WIZMANU TEXT("sti_ci.dll,WiaCreateWizardMenu")
  89. #define LAYOUT_INF_PATH TEXT("\\inf\\layout.inf")
  90. #define SOURCEDISKFILES TEXT("SourceDisksFiles")
  91. #define PROVIDER TEXT("Provider")
  92. #define MICROSOFT TEXT("Microsoft")
  93. #define PORTSELECT TEXT("PortSelect")
  94. #define WIAINSTALLERMUTEX TEXT("WiaInstallerMutex")
  95. #define WIAINSTALLWIZMUTEX TEXT("WiaInstallWizMutex")
  96. #define WIAINSTALLERFILENAME TEXT("sti_ci.dll")
  97. #define WIAWIZARDCHORCUTNAME TEXT("Scanner and Camera Wizard")
  98. #define MESSAGE1 TEXT("Message1")
  99. #define NEWDEVDLL TEXT("newdev.dll")
  100. #define BUTTON_NOT_PUSHED 0
  101. #define BUTTON_NEXT 1
  102. #define BUTTON_BACK 2
  103. #define PORTSELMODE_NORMAL 0
  104. #define PORTSELMODE_SKIP 1
  105. #define PORTSELMODE_MESSAGE1 2
  106. #ifndef DLLEXPORT
  107. #define DLLEXPORT __declspec(dllexport)
  108. #endif // DLLEXPORT
  109. //
  110. // Registry Paths
  111. //
  112. #define REGKEY_DEVICE_PARMS TEXT("Device Parameters")
  113. #define REGKEY_CONTROLINIFILEMAPPING TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\control.ini")
  114. #define REGSTR_VAL_FRIENDLY_NAME TEXT("FriendlyName")
  115. #define REGSTR_VAL_FRIENDLY_NAME_A "FriendlyName"
  116. #define REGSTR_VAL_DEVICE_ID TEXT("DeviceID")
  117. #define REGSTR_VAL_WIZMENU TEXT("WIAWizardMenu")
  118. #define REGKEY_WIASHEXT TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\NameSpace\\DelegateFolders\\{E211B736-43FD-11D1-9EFB-0000F8757FCD}")
  119. #define REGKEY_INSTALL_NAMESTORE TEXT("SYSTEM\\CurrentControlSet\\Control\\StillImage\\DeviceNameStore")
  120. #define REGSTR_VAL_WIASHEXT TEXT("Scanners & Cameras")
  121. //
  122. // Migration
  123. //
  124. #define NAME_BEGIN_A "BEGIN"
  125. #define NAME_BEGIN_W L"BEGIN"
  126. #define NAME_END_A "END"
  127. #define NAME_END_W L"END"
  128. //
  129. // Macro
  130. //
  131. #ifdef UNICODE
  132. #define AtoT(_d_, _s_) MultiByteToWideChar(CP_ACP, 0, _s_, -1, _d_, MAX_FRIENDLYNAME+1);
  133. #else // UNICODE
  134. #define AtoT(_d_, _s_)
  135. #endif // UNICODE
  136. #define IS_VALID_HANDLE(h) (((h) != NULL) && ((h) != INVALID_HANDLE_VALUE))
  137. #ifndef ARRAYSIZE
  138. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  139. #endif
  140. //
  141. // Struct
  142. //
  143. typedef struct _INSTALLER_CONTEXT {
  144. HDEVINFO hDevInfo;
  145. SP_DEVINFO_DATA spDevInfoData;
  146. HWND hwndWizard;
  147. PVOID pFirstPage;
  148. PVOID pPrevSelectPage;
  149. PVOID pPortSelectPage;
  150. PVOID pNameDevicePage;
  151. PVOID pFinalPage;
  152. PVOID pDevice;
  153. BOOL bShowFirstPage;
  154. BOOL bCalledFromControlPanal;
  155. UCHAR szPortName[MAX_DESCRIPTION];
  156. } INSTALLER_CONTEXT, *PINSTALLER_CONTEXT;
  157. // For migration.
  158. typedef struct _PARAM_LIST {
  159. PVOID pNext;
  160. LPSTR pParam1;
  161. LPSTR pParam2;
  162. } PARAM_LIST, *PPARAM_LIST;
  163. typedef struct _DEVICE_INFO {
  164. LPSTR pszFriendlyName;
  165. LPSTR pszCreateFileName;
  166. LPSTR pszInfPath;
  167. LPSTR pszInfSection;
  168. DWORD dwNumberOfDeviceDataKey;
  169. PPARAM_LIST pDeviceDataParam;
  170. } DEVICE_INFO, *PDEVICE_INFO;
  171. //
  172. // Prototype
  173. //
  174. BOOL
  175. GetInfInforamtionFromSelectedDevice(
  176. HDEVINFO hDevInfo,
  177. LPTSTR pInfFileName,
  178. LPTSTR pInfSectionName
  179. );
  180. BOOL
  181. GetStringFromRegistry(
  182. HKEY hkRegistry,
  183. LPCTSTR szValueName,
  184. LPTSTR pBuffer
  185. );
  186. BOOL
  187. GetDwordFromRegistry(
  188. HKEY hkRegistry,
  189. LPCTSTR szValueName,
  190. LPDWORD pdwValue
  191. );
  192. VOID
  193. ShowInstallerMessage(
  194. DWORD dwMessageId
  195. );
  196. VOID
  197. SetRunonceKey(
  198. LPTSTR szValue,
  199. LPTSTR szData
  200. );
  201. DWORD
  202. DecodeHexA(
  203. LPSTR lpstr
  204. );
  205. BOOL
  206. IsWindowsFile(
  207. LPTSTR szFileName
  208. );
  209. BOOL
  210. IsProviderMs(
  211. LPTSTR szInfName
  212. );
  213. BOOL
  214. IsIhvAndInboxExisting(
  215. HDEVINFO hDevInfo,
  216. PSP_DEVINFO_DATA pDevInfoData
  217. );
  218. BOOL
  219. IsNameAlreadyStored(
  220. LPTSTR szName
  221. );
  222. HFONT
  223. GetIntroFont(
  224. HWND hwnd
  225. );
  226. BOOL
  227. IsDeviceRootEnumerated(
  228. IN HDEVINFO hDevInfo,
  229. IN PSP_DEVINFO_DATA pDevInfoData
  230. );
  231. int
  232. MyStrCmpi(
  233. LPCTSTR str1,
  234. LPCTSTR str2
  235. );
  236. // from entry.cpp
  237. extern "C"
  238. DWORD
  239. APIENTRY
  240. CoinstallerEntry(
  241. IN DI_FUNCTION diFunction,
  242. IN HDEVINFO hDevInfo,
  243. IN PSP_DEVINFO_DATA pDevInfoData,
  244. IN OUT PCOINSTALLER_CONTEXT_DATA pCoinstallerContext
  245. );
  246. DWORD
  247. APIENTRY
  248. CoinstallerPreProcess(
  249. IN DI_FUNCTION diFunction,
  250. IN HDEVINFO hDevInfo,
  251. IN PSP_DEVINFO_DATA pDevInfoData,
  252. IN OUT PCOINSTALLER_CONTEXT_DATA pCoinstallerContext
  253. );
  254. DWORD
  255. APIENTRY
  256. CoinstallerPostProcess(
  257. IN DI_FUNCTION diFunction,
  258. IN HDEVINFO hDevInfo,
  259. IN PSP_DEVINFO_DATA pDevInfoData,
  260. IN OUT PCOINSTALLER_CONTEXT_DATA pCoinstallerContext
  261. );
  262. //
  263. // Class
  264. //
  265. class CInstallerMutex {
  266. private:
  267. HANDLE *m_phMutex;
  268. BOOL m_bSucceeded;
  269. public:
  270. CInstallerMutex(HANDLE* phMutex, LPTSTR szMutexName, DWORD dwTimeout);
  271. ~CInstallerMutex();
  272. inline BOOL Succeeded() {
  273. return m_bSucceeded;
  274. }
  275. };
  276. #endif // _STI_CI_H_