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.

524 lines
8.2 KiB

  1. /* Copyright (c) 1995, Microsoft Corporation, all rights reserved
  2. **
  3. ** nouiutil.h
  4. ** No UI helper routines (no HWNDs required)
  5. ** Public header
  6. **
  7. ** 08/25/95 Steve Cobb
  8. */
  9. #pragma once
  10. #ifndef _NOUIUTIL_H_
  11. #define _NOUIUTIL_H_
  12. /* Maximum length of string returned by LToT without terminating null.
  13. */
  14. #define MAXLTOTLEN 11
  15. /* Heap allocation macros allowing easy substitution of alternate heap. These
  16. ** are used by the other utility sections.
  17. */
  18. #ifndef EXCL_HEAPDEFS
  19. #define Malloc(c) (void*)GlobalAlloc(0,(c))
  20. #define Realloc(p,c) (void*)GlobalReAlloc((p),(c),GMEM_MOVEABLE)
  21. #define Free(p) (void*)GlobalFree(p)
  22. #endif
  23. /* Bits returned by GetInstalledProtocols.
  24. */
  25. #define NP_Nbf 0x1
  26. #define NP_Ipx 0x2
  27. #define NP_Ip 0x4
  28. #define NP_Netmon 0x8
  29. /* Definition of comparison function required by ShellSort and
  30. ** ShellSortIndirect.
  31. ** The comparison is essentially <arg1> - <arg2>, thus the function should
  32. ** return negative if the first item is less than the second, zero
  33. ** if the items are equal, and positive if the first item is greater
  34. ** than the second.
  35. */
  36. typedef INT (*PFNCOMPARE)( VOID*, VOID* );
  37. /* Linked list library.
  38. */
  39. #ifndef EXCL_DTL_H
  40. #include <dtl.h>
  41. #endif
  42. /* International formatting library.
  43. */
  44. #ifndef EXCL_INTL_H
  45. #include <intl.h>
  46. #endif
  47. /* User preference library.
  48. */
  49. #ifndef EXCL_PBUSER_H
  50. #include <pbuser.h>
  51. #endif
  52. /* RasApi utility library.
  53. */
  54. #ifndef EXCL_RAUTIL_H
  55. #include <rautil.h>
  56. #endif
  57. /* RasMan utility library.
  58. */
  59. #ifndef EXCL_RMUTIL_H
  60. #include <rmutil.h>
  61. #endif
  62. /* RAS DLL entrypoint loader library.
  63. */
  64. #ifndef EXCL_LOADDLLS_H
  65. #include <loaddlls.h>
  66. #endif
  67. /* EAP configuration utility library.
  68. */
  69. #ifndef EXCL_EAPCFG_H
  70. #include <eapcfg.h>
  71. #endif
  72. /* Node types used by MultiSz calls.
  73. */
  74. #define NT_Psz 1
  75. #define NT_Kv 2
  76. //
  77. // Defs to determine which entrypoint to load
  78. //
  79. #define CUSTOM_RASDIALDLG 0
  80. #define CUSTOM_RASENTRYDLG 1
  81. #define CUSTOM_RASDIAL 2
  82. #define CUSTOM_RASDELETEENTRYNOTIFY 3
  83. /*----------------------------------------------------------------------------
  84. ** Datatypes
  85. **----------------------------------------------------------------------------
  86. */
  87. /* Key/Value string pair. The contents of a Kv node.
  88. */
  89. #define KEYVALUE struct tagKEYVALUE
  90. KEYVALUE
  91. {
  92. TCHAR* pszKey;
  93. TCHAR* pszValue;
  94. };
  95. /* RAS-relevant Unimodem settings.
  96. */
  97. #define UNIMODEMINFO struct tagUNIMODEMINFO
  98. UNIMODEMINFO
  99. {
  100. BOOL fHwFlow;
  101. BOOL fEc;
  102. BOOL fEcc;
  103. DWORD dwBps;
  104. BOOL fSpeaker;
  105. BOOL fOperatorDial;
  106. BOOL fUnimodemPreTerminal;
  107. DWORD dwModemProtocol; // selected modem protocol
  108. DTLLIST *pListProtocols; // list of available protocols
  109. };
  110. /*----------------------------------------------------------------------------
  111. ** Prototypes
  112. **----------------------------------------------------------------------------
  113. */
  114. INT
  115. ComparePszNode(
  116. IN DTLNODE* pNode1,
  117. IN DTLNODE* pNode2 );
  118. DWORD
  119. CreateDirectoriesOnPath(
  120. LPTSTR pszPath,
  121. LPSECURITY_ATTRIBUTES psa);
  122. DTLNODE*
  123. CreateKvNode(
  124. IN LPCTSTR pszKey,
  125. IN LPCTSTR pszValue );
  126. DTLNODE*
  127. CreatePszNode(
  128. IN LPCTSTR psz );
  129. VOID
  130. DestroyKvNode(
  131. IN DTLNODE* pdtlnode );
  132. VOID
  133. DestroyPszNode(
  134. IN DTLNODE* pdtlnode );
  135. BOOL
  136. DeviceAndPortFromPsz(
  137. IN TCHAR* pszDP,
  138. OUT TCHAR** ppszDevice,
  139. OUT TCHAR** ppszPort );
  140. DTLNODE*
  141. DuplicateKvNode(
  142. IN DTLNODE* pdtlnode );
  143. DTLNODE*
  144. DuplicatePszNode(
  145. IN DTLNODE* pdtlnode );
  146. BOOL
  147. FFileExists(
  148. IN TCHAR* pszPath );
  149. BOOL
  150. FIsTcpipInstalled();
  151. BOOL
  152. FIsUserAdminOrPowerUser();
  153. VOID*
  154. Free0(
  155. VOID* p );
  156. //for utilsys.c
  157. TCHAR*
  158. GetComputer(
  159. void );
  160. TCHAR*
  161. GetLogonDomain(
  162. void );
  163. TCHAR*
  164. GetLogonUser(
  165. void );
  166. BOOL
  167. IsFirewallAvailablePlatform(
  168. void);
  169. BOOL
  170. IsAdvancedServerPlatform(
  171. void);
  172. BOOL
  173. IsPersonalPlatform(
  174. void);
  175. BOOL
  176. IsStandaloneWKS(
  177. void);
  178. BOOL
  179. IsConsumerPlatform(
  180. void);
  181. //end of definitions for utilsys.c
  182. DWORD
  183. GetInstalledProtocols(
  184. VOID );
  185. DWORD
  186. GetInstalledProtocolsEx(
  187. HANDLE hConnection,
  188. BOOL fRouter,
  189. BOOL fRasCli,
  190. BOOL fRasSrv );
  191. VOID
  192. GetRegBinary(
  193. IN HKEY hkey,
  194. IN TCHAR* pszName,
  195. OUT BYTE** ppbResult,
  196. OUT DWORD* pcbResult );
  197. VOID
  198. GetRegDword(
  199. IN HKEY hkey,
  200. IN TCHAR* pszName,
  201. OUT DWORD* pdwResult );
  202. DWORD
  203. GetRegExpandSz(
  204. IN HKEY hkey,
  205. IN TCHAR* pszName,
  206. OUT TCHAR** ppszResult );
  207. DWORD
  208. GetRegMultiSz(
  209. IN HKEY hkey,
  210. IN TCHAR* pszName,
  211. IN OUT DTLLIST** ppListResult,
  212. IN DWORD dwNodeType );
  213. DWORD
  214. GetRegSz(
  215. IN HKEY hkey,
  216. IN TCHAR* pszName,
  217. OUT TCHAR** ppszResult );
  218. DWORD
  219. GetRegSzz(
  220. IN HKEY hkey,
  221. IN TCHAR* pszName,
  222. OUT TCHAR** ppszResult );
  223. CHAR
  224. HexChar(
  225. IN BYTE byte );
  226. BYTE
  227. HexValue(
  228. IN CHAR byte );
  229. void
  230. IpHostAddrToPsz(
  231. IN DWORD dwAddr,
  232. OUT LPTSTR pszBuffer );
  233. BOOL
  234. IsAllWhite(
  235. IN LPCTSTR psz );
  236. BOOL
  237. IsNullTerminatedA(
  238. IN CHAR* psz,
  239. IN DWORD dwSize );
  240. DWORD
  241. IpPszToHostAddr(
  242. IN LPCTSTR cp );
  243. DWORD
  244. GetRasUnimodemBlob(
  245. IN HANDLE hConnection,
  246. IN HPORT hport,
  247. IN CHAR* pszDeviceType,
  248. OUT BYTE** ppBlob,
  249. OUT DWORD* pcbBlob );
  250. DWORD
  251. GetRasUnimodemBlobEx(
  252. IN HANDLE hConnection,
  253. IN HPORT hport,
  254. IN CHAR* pszDeviceType,
  255. IN BOOL fGlobal,
  256. OUT BYTE** ppBlob,
  257. OUT DWORD* pcbBlob );
  258. VOID
  259. GetRasUnimodemInfo(
  260. IN HANDLE hConnection,
  261. IN HPORT hport,
  262. IN CHAR* pszDeviceType,
  263. OUT UNIMODEMINFO* pInfo );
  264. TCHAR*
  265. LToT(
  266. LONG lValue,
  267. TCHAR* pszBuf,
  268. INT nRadix );
  269. TCHAR*
  270. PszFromDeviceAndPort(
  271. IN TCHAR* pszDevice,
  272. IN TCHAR* pszPort );
  273. LPCTSTR
  274. PszLoadStringPcch (
  275. HINSTANCE hinst,
  276. UINT unId,
  277. int* pcch);
  278. LPCTSTR
  279. PszLoadString (
  280. HINSTANCE hinst,
  281. UINT unId);
  282. DWORD
  283. RegDeleteTree(
  284. IN HKEY RootKey,
  285. IN TCHAR* SubKeyName );
  286. BOOL
  287. RegValueExists(
  288. IN HKEY hkey,
  289. IN TCHAR* pszValue );
  290. BOOL
  291. RestartComputer();
  292. TCHAR*
  293. StripPath(
  294. IN TCHAR* pszPath );
  295. LONG
  296. TToL(
  297. TCHAR *pszBuf );
  298. TCHAR*
  299. PszFromError(
  300. IN DWORD dwError );
  301. TCHAR*
  302. PszFromId(
  303. IN HINSTANCE hInstance,
  304. IN DWORD dwStringId );
  305. BOOL
  306. RestartComputer();
  307. VOID
  308. SanitizeUnimodemBlob(
  309. IN OUT BYTE* pBlob );
  310. VOID
  311. SetDefaultUnimodemInfo(
  312. OUT UNIMODEMINFO* pInfo );
  313. HFONT
  314. SetFont(
  315. HWND hwndCtrl,
  316. TCHAR* pszFaceName,
  317. BYTE bfPitchAndFamily,
  318. INT nPointSize,
  319. BOOL fUnderline,
  320. BOOL fStrikeout,
  321. BOOL fItalic,
  322. BOOL fBold );
  323. DWORD
  324. SetRegDword(
  325. IN HKEY hkey,
  326. IN TCHAR* pszName,
  327. IN DWORD dwValue );
  328. DWORD
  329. SetRegMultiSz(
  330. IN HKEY hkey,
  331. IN TCHAR* pszName,
  332. IN DTLLIST* pListValues,
  333. IN DWORD dwNodeType );
  334. DWORD
  335. SetRegSz(
  336. IN HKEY hkey,
  337. IN TCHAR* pszName,
  338. IN TCHAR* pszValue );
  339. DWORD
  340. SetRegSzz(
  341. IN HKEY hkey,
  342. IN TCHAR* pszName,
  343. IN TCHAR* pszValue );
  344. DWORD
  345. ShellSort(
  346. IN VOID* pItemTable,
  347. IN DWORD dwItemSize,
  348. IN DWORD dwItemCount,
  349. IN PFNCOMPARE pfnCompare );
  350. VOID
  351. ShellSortIndirect(
  352. IN VOID* pItemTable,
  353. IN VOID** ppItemTable,
  354. IN DWORD dwItemSize,
  355. IN DWORD dwItemCount,
  356. IN PFNCOMPARE pfnCompare );
  357. TCHAR*
  358. StrDup(
  359. LPCTSTR psz );
  360. CHAR*
  361. StrDupAFromT(
  362. LPCTSTR psz );
  363. CHAR*
  364. StrDupAFromTAnsi(
  365. LPCTSTR psz);
  366. TCHAR*
  367. StrDupTFromA(
  368. LPCSTR psz );
  369. TCHAR*
  370. StrDupTFromW(
  371. LPCWSTR psz );
  372. WCHAR*
  373. StrDupWFromA(
  374. LPCSTR psz );
  375. TCHAR*
  376. StrDupTFromAUsingAnsiEncoding(
  377. LPCSTR psz );
  378. WCHAR*
  379. StrDupWFromAUsingAnsiEncoding(
  380. LPCSTR psz );
  381. WCHAR*
  382. StrDupWFromT(
  383. LPCTSTR psz );
  384. DWORD
  385. StrCpyWFromA(
  386. WCHAR* pszDst,
  387. LPCSTR pszSrc,
  388. DWORD dwDstChars);
  389. DWORD
  390. StrCpyAFromW(
  391. LPSTR pszDst,
  392. LPCWSTR pszSrc,
  393. DWORD dwDstChars);
  394. DWORD
  395. StrCpyWFromAUsingAnsiEncoding(
  396. WCHAR* pszDst,
  397. LPCSTR pszSrc,
  398. DWORD dwDstChars);
  399. DWORD
  400. StrCpyAFromWUsingAnsiEncoding(
  401. LPSTR pszDst,
  402. LPCWSTR pszSrc,
  403. DWORD dwDstChars);
  404. int
  405. StrNCmpA(
  406. IN CHAR* psz1,
  407. IN CHAR* psz2,
  408. IN INT nLen );
  409. CHAR*
  410. StrStrA(
  411. IN CHAR* psz1,
  412. IN CHAR* psz2 );
  413. VOID
  414. UnimodemInfoFromBlob(
  415. IN BYTE* pBlob,
  416. OUT UNIMODEMINFO* pInfo );
  417. VOID
  418. UnimodemInfoToBlob(
  419. IN UNIMODEMINFO* pInfo,
  420. IN OUT BYTE* pBlob );
  421. TCHAR*
  422. UnNull(
  423. TCHAR* psz );
  424. #endif // _NOUIUTIL_H_