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.

832 lines
21 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <tchar.h>
  5. #include "faxutil.h"
  6. DWORD SetLTRWindowLayout(HWND hWnd);
  7. DWORD SetLTREditBox(HWND hEdit);
  8. typedef LANGID (*GETUSERDEFAULTUILANGUAGE)(void);
  9. typedef BOOL (*ISVALIDLANGUAGEGROUP)(LGRPID LanguageGroup,DWORD dwFlags);
  10. ///////////////////////////////////////////////////////////////////////////////////////
  11. // Function:
  12. // MyGetUserDefaultUILanguage
  13. //
  14. // Purpose:
  15. // enable calling the API without creating a dependency on the API
  16. // being exported by kernel32.dll, to enable our binaries that use util.lib
  17. // to load on NT4 (which does not support this API)
  18. // we keep an open handle to the module which will be cleaned up
  19. // only upon the process termination.
  20. //
  21. // Params:
  22. // None
  23. //
  24. // Return Value:
  25. // LANGID - result of GetUserDefaultUILanguage
  26. // -1 - in case the API is not exported by KERNEL32.DLL
  27. //
  28. // Author:
  29. // Mooly Beery (MoolyB) 30-Jul-2001
  30. ///////////////////////////////////////////////////////////////////////////////////////
  31. LANGID MyGetUserDefaultUILanguage()
  32. {
  33. LANGID LangId = 0;
  34. static HMODULE hModule = NULL;
  35. GETUSERDEFAULTUILANGUAGE pfGetUserDefaultUiLanguage = NULL;
  36. DEBUG_FUNCTION_NAME(TEXT("MyGetUserDefaultUILanguage"));
  37. if (hModule==NULL)
  38. {
  39. hModule = LoadLibrary(_T("Kernel32.dll"));
  40. if (hModule==NULL)
  41. {
  42. DebugPrintEx(DEBUG_ERR,TEXT("LoadLibrary(Kernel32.dll) failed (ec=%d)"),GetLastError());
  43. goto exit;
  44. }
  45. }
  46. pfGetUserDefaultUiLanguage = (GETUSERDEFAULTUILANGUAGE)GetProcAddress(hModule,"GetUserDefaultUILanguage");
  47. if (pfGetUserDefaultUiLanguage==NULL)
  48. {
  49. DebugPrintEx(DEBUG_ERR,TEXT("GetProcAddress(GetUserDefaultUILanguage) failed (ec=%d)"),GetLastError());
  50. LangId = -1;
  51. goto exit;
  52. }
  53. LangId = (*pfGetUserDefaultUiLanguage)();
  54. exit:
  55. return LangId;
  56. }
  57. ///////////////////////////////////////////////////////////////////////////////////////
  58. // Function:
  59. // MyIsValidLanguageGroup
  60. //
  61. // Purpose:
  62. // enable calling the API without creating a dependency on the API
  63. // being exported by kernel32.dll, to enable our binaries that use util.lib
  64. // to load on NT4 (which does not support this API)
  65. // we keep an open handle to the module which will be cleaned up
  66. // only upon the process termination.
  67. //
  68. // Params:
  69. // None
  70. //
  71. // Return Value:
  72. // the result of IsValidLanguageGroup
  73. // FALSE - in case of failure
  74. //
  75. // Author:
  76. // Mooly Beery (MoolyB) 30-Jul-2001
  77. ///////////////////////////////////////////////////////////////////////////////////////
  78. BOOL MyIsValidLanguageGroup(LGRPID LanguageGroup,DWORD dwFlags)
  79. {
  80. BOOL bRet = TRUE;
  81. static HMODULE hModule = NULL;
  82. ISVALIDLANGUAGEGROUP pfIsValidLanguageGroup = NULL;
  83. DEBUG_FUNCTION_NAME(TEXT("MyIsValidLanguageGroup"));
  84. if (hModule==NULL)
  85. {
  86. hModule = LoadLibrary(_T("Kernel32.dll"));
  87. if (hModule==NULL)
  88. {
  89. DebugPrintEx(DEBUG_ERR,TEXT("LoadLibrary(Kernel32.dll) failed (ec=%d)"),GetLastError());
  90. bRet = FALSE;
  91. goto exit;
  92. }
  93. }
  94. pfIsValidLanguageGroup = (ISVALIDLANGUAGEGROUP)GetProcAddress(hModule,"IsValidLanguageGroup");
  95. if (pfIsValidLanguageGroup==NULL)
  96. {
  97. DebugPrintEx(DEBUG_ERR,TEXT("GetProcAddress(IsValidLanguageGroup) failed (ec=%d)"),GetLastError());
  98. bRet = FALSE;
  99. goto exit;
  100. }
  101. bRet = (*pfIsValidLanguageGroup)(LanguageGroup,dwFlags);
  102. exit:
  103. return bRet;
  104. }
  105. ///////////////////////////////////////////////////////////////////////////////////////
  106. // Function:
  107. // IsRTLUILanguage
  108. //
  109. // Purpose:
  110. // Determine User Default UI Language layout
  111. //
  112. // Return Value:
  113. // TRUE if the User Default UI Language has Right-to-Left layout
  114. // FALSE otherwise
  115. ///////////////////////////////////////////////////////////////////////////////////////
  116. BOOL
  117. IsRTLUILanguage()
  118. {
  119. #if(WINVER >= 0x0500)
  120. LANGID langID; // language identifier for the current user language
  121. WORD primLangID; // primary language identifier
  122. DEBUG_FUNCTION_NAME(TEXT("IsRTLUILanguage"));
  123. langID = MyGetUserDefaultUILanguage();
  124. if(langID == 0)
  125. {
  126. DebugPrintEx(DEBUG_ERR,TEXT("GetUserDefaultUILanguage failed."));
  127. return TRUE;
  128. }
  129. primLangID = PRIMARYLANGID(langID);
  130. if(LANG_ARABIC == primLangID ||
  131. LANG_HEBREW == primLangID)
  132. {
  133. //
  134. // If the UI Language is Arabic or Hebrew the layout is Right-to-Left
  135. //
  136. return TRUE;
  137. }
  138. #endif /* WINVER >= 0x0500 */
  139. return FALSE;
  140. }
  141. ///////////////////////////////////////////////////////////////////////////////////////
  142. // Function:
  143. // IsWindowRTL
  144. //
  145. // Purpose:
  146. // Determine if the window has RTL layout
  147. //
  148. // Params:
  149. // hWnd - window handle
  150. // Return Value:
  151. // TRUE if the window has RTL layout
  152. // FALSE otherwise
  153. ///////////////////////////////////////////////////////////////////////////////////////
  154. BOOL
  155. IsWindowRTL(
  156. HWND hWnd
  157. )
  158. {
  159. BOOL bRes = FALSE;
  160. #if(WINVER >= 0x0500)
  161. LONG_PTR style;
  162. style = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
  163. if(WS_EX_LAYOUTRTL == (style & WS_EX_LAYOUTRTL))
  164. {
  165. bRes = TRUE;
  166. }
  167. #endif /* WINVER >= 0x0500 */
  168. return bRes;
  169. }
  170. ///////////////////////////////////////////////////////////////////////////////////////
  171. // Function:
  172. // SetLTRControlLayout
  173. //
  174. // Purpose:
  175. // Set left-to-right layout for a dialog control
  176. // if the user default UI has RTL layout
  177. //
  178. // Params:
  179. // hDlg - Dialog handle
  180. // dwCtrlID - control ID
  181. //
  182. // Return Value:
  183. // standard error code
  184. ///////////////////////////////////////////////////////////////////////////////////////
  185. DWORD
  186. SetLTRControlLayout(
  187. HWND hDlg,
  188. DWORD dwCtrlID
  189. )
  190. {
  191. DWORD dwRes = ERROR_SUCCESS;
  192. #if(WINVER >= 0x0500)
  193. HWND hCtrl;
  194. DEBUG_FUNCTION_NAME(TEXT("SetLTRControlLayout"));
  195. if(!hDlg || !dwCtrlID)
  196. {
  197. Assert(FALSE);
  198. return ERROR_INVALID_PARAMETER;
  199. }
  200. if(!IsWindowRTL(hDlg))
  201. {
  202. //
  203. // The dialog is not RTL
  204. // So, no need to revert control
  205. //
  206. return dwRes;
  207. }
  208. //
  209. // Get Control box handle
  210. //
  211. hCtrl = GetDlgItem(hDlg, dwCtrlID);
  212. if(!hCtrl)
  213. {
  214. dwRes = GetLastError();
  215. DebugPrintEx(DEBUG_ERR,TEXT("GetDlgItem failed with %ld."),dwRes);
  216. return dwRes;
  217. }
  218. dwRes = SetLTRWindowLayout(hCtrl);
  219. if(ERROR_SUCCESS != dwRes)
  220. {
  221. DebugPrintEx(DEBUG_ERR,TEXT("SetLTRWindowLayout failed with %ld."),dwRes);
  222. }
  223. #endif /* WINVER >= 0x0500 */
  224. return dwRes;
  225. } // SetLTRControlLayout
  226. ///////////////////////////////////////////////////////////////////////////////////////
  227. // Function:
  228. // SetLTREditDirection
  229. //
  230. // Purpose:
  231. // Set left aligment for an dialog edit box
  232. // if the user default UI has RTL layout
  233. //
  234. // Params:
  235. // hDlg - Dialog handle
  236. // dwEditID - Edit box control ID
  237. //
  238. // Return Value:
  239. // standard error code
  240. ///////////////////////////////////////////////////////////////////////////////////////
  241. DWORD
  242. SetLTREditDirection(
  243. HWND hDlg,
  244. DWORD dwEditID
  245. )
  246. {
  247. DWORD dwRes = ERROR_SUCCESS;
  248. #if(WINVER >= 0x0500)
  249. HWND hCtrl;
  250. DEBUG_FUNCTION_NAME(TEXT("SetLtrEditDirection"));
  251. if(!hDlg || !dwEditID)
  252. {
  253. Assert(FALSE);
  254. return ERROR_INVALID_PARAMETER;
  255. }
  256. if(!IsWindowRTL(hDlg))
  257. {
  258. //
  259. // The dialog is not RTL
  260. // So, no need to revert control
  261. //
  262. return dwRes;
  263. }
  264. //
  265. // Get Edit box handle
  266. //
  267. hCtrl = GetDlgItem(hDlg, dwEditID);
  268. if(!hCtrl)
  269. {
  270. dwRes = GetLastError();
  271. DebugPrintEx(DEBUG_ERR,TEXT("GetDlgItem failed with %ld."),dwRes);
  272. return dwRes;
  273. }
  274. dwRes = SetLTREditBox(hCtrl);
  275. if(ERROR_SUCCESS != dwRes)
  276. {
  277. DebugPrintEx(DEBUG_ERR,TEXT("SetLTREditBox failed with %ld."),dwRes);
  278. }
  279. #endif /* WINVER >= 0x0500 */
  280. return dwRes;
  281. } // SetLTREditDirection
  282. //////////////////////////////////////////////////////////////////////////////////////
  283. // Function:
  284. // SetLTRWindowLayout
  285. //
  286. // Purpose:
  287. // Set left-to-right layout for a window
  288. // if the user default UI has RTL layout
  289. //
  290. // Params:
  291. // hWnd - Window handle
  292. //
  293. // Return Value:
  294. // standard error code
  295. //////////////////////////////////////////////////////////////////////////////////////
  296. DWORD
  297. SetLTRWindowLayout(
  298. HWND hWnd
  299. )
  300. {
  301. DWORD dwRes = ERROR_SUCCESS;
  302. #if(WINVER >= 0x0500)
  303. LONG_PTR style;
  304. DEBUG_FUNCTION_NAME(TEXT("SetLTRWindowLayout"));
  305. if(!hWnd)
  306. {
  307. Assert(FALSE);
  308. return ERROR_INVALID_PARAMETER;
  309. }
  310. //
  311. // Remove RTL and add LTR to ExStyle
  312. //
  313. style = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
  314. style &= ~(WS_EX_LAYOUTRTL | WS_EX_RIGHT | WS_EX_RTLREADING);
  315. style |= WS_EX_LEFT | WS_EX_LTRREADING;
  316. SetWindowLongPtr(hWnd, GWL_EXSTYLE, style);
  317. //
  318. // Refresh the window
  319. //
  320. if(!SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED))
  321. {
  322. dwRes = GetLastError();
  323. DebugPrintEx(DEBUG_ERR,TEXT("SetWindowPos failed with %ld."),dwRes);
  324. }
  325. #endif /* WINVER >= 0x0500 */
  326. return dwRes;
  327. } // SetLTRWindowLayout
  328. //////////////////////////////////////////////////////////////////////////////////////
  329. // Function:
  330. // SetLTREditBox
  331. //
  332. // Purpose:
  333. // Set left aligment for an dialog edit box
  334. // if the user default UI has RTL layout
  335. //
  336. // Params:
  337. // hEdit - edit box handle
  338. //
  339. // Return Value:
  340. // standard error code
  341. //////////////////////////////////////////////////////////////////////////////////////
  342. DWORD
  343. SetLTREditBox(
  344. HWND hEdit
  345. )
  346. {
  347. DWORD dwRes = ERROR_SUCCESS;
  348. #if(WINVER >= 0x0500)
  349. LONG_PTR style;
  350. DEBUG_FUNCTION_NAME(TEXT("SetLTREditBox"));
  351. if(!hEdit)
  352. {
  353. Assert(FALSE);
  354. return ERROR_INVALID_PARAMETER;
  355. }
  356. //
  357. // Remove RTL and add LTR to Style
  358. //
  359. style = GetWindowLongPtr(hEdit, GWL_STYLE);
  360. style &= ~ES_RIGHT;
  361. style |= ES_LEFT;
  362. SetWindowLongPtr(hEdit, GWL_STYLE, style);
  363. dwRes = SetLTRWindowLayout(hEdit);
  364. if(ERROR_SUCCESS != dwRes)
  365. {
  366. DebugPrintEx(DEBUG_ERR,TEXT("SetLTRWindowLayout failed with %ld."),dwRes);
  367. }
  368. #endif /* WINVER >= 0x0500 */
  369. return dwRes;
  370. } // SetLTREditBox
  371. //////////////////////////////////////////////////////////////////////////////////////
  372. // Function:
  373. // SetLTRComboBox
  374. //
  375. // Purpose:
  376. // Set left aligment for an dialog combo box
  377. // if the user default UI has RTL layout
  378. //
  379. // Params:
  380. // hDlg - Dialog handle
  381. // dwCtrlID - combo box control ID
  382. //
  383. // Return Value:
  384. // standard error code
  385. //////////////////////////////////////////////////////////////////////////////////////
  386. DWORD
  387. SetLTRComboBox(
  388. HWND hDlg,
  389. DWORD dwCtrlID
  390. )
  391. {
  392. DWORD dwRes = ERROR_SUCCESS;
  393. #if(WINVER >= 0x0500)
  394. HWND hCtrl;
  395. COMBOBOXINFO comboBoxInfo = {0};
  396. HMODULE hUser32 = NULL;
  397. BOOL (*pfGetComboBoxInfo)(HWND, PCOMBOBOXINFO) = NULL;
  398. DEBUG_FUNCTION_NAME(TEXT("SetLTRComboBox"));
  399. if((LOBYTE(LOWORD(GetVersion()))) < 5)
  400. {
  401. //
  402. // OS version less then Windows 2000
  403. // WS_EX_LAYOUTRTL extended windows style requires Windows 2000 or later
  404. //
  405. return ERROR_CALL_NOT_IMPLEMENTED;
  406. }
  407. if(!hDlg || !dwCtrlID)
  408. {
  409. Assert(FALSE);
  410. return ERROR_INVALID_PARAMETER;
  411. }
  412. if(!IsWindowRTL(hDlg))
  413. {
  414. //
  415. // The dialog is not RTL
  416. // So, no need to revert control
  417. //
  418. return dwRes;
  419. }
  420. //
  421. // Get combo box handle
  422. //
  423. hCtrl = GetDlgItem(hDlg, dwCtrlID);
  424. if(!hCtrl)
  425. {
  426. dwRes = GetLastError();
  427. DebugPrintEx(DEBUG_ERR,TEXT("GetDlgItem failed with %ld."),dwRes);
  428. return dwRes;
  429. }
  430. //
  431. // GetComboBoxInfo() requires Windows NT 4.0 SP6 or later
  432. // so we connect dynamically to it
  433. //
  434. hUser32 = LoadLibrary(TEXT("user32.dll"));
  435. if(!hUser32)
  436. {
  437. dwRes = GetLastError();
  438. DebugPrintEx(DEBUG_ERR,TEXT("LoadLibrary(user32.dll) failed with %ld."),dwRes);
  439. goto exit;
  440. }
  441. (FARPROC&)pfGetComboBoxInfo = GetProcAddress(hUser32, "GetComboBoxInfo");
  442. if(!pfGetComboBoxInfo)
  443. {
  444. dwRes = GetLastError();
  445. DebugPrintEx(DEBUG_ERR,TEXT("GetProcAddress(GetComboBoxInfo) failed with %ld."),dwRes);
  446. goto exit;
  447. }
  448. comboBoxInfo.cbSize = sizeof(comboBoxInfo);
  449. if(pfGetComboBoxInfo(hCtrl, &comboBoxInfo))
  450. {
  451. SetLTREditBox(comboBoxInfo.hwndItem);
  452. SetLTRWindowLayout(comboBoxInfo.hwndCombo);
  453. SetLTRWindowLayout(comboBoxInfo.hwndList);
  454. }
  455. else
  456. {
  457. dwRes = GetLastError();
  458. DebugPrintEx(DEBUG_ERR,TEXT("GetComboBoxInfo failed with %ld."),dwRes);
  459. goto exit;
  460. }
  461. exit:
  462. if(hUser32)
  463. {
  464. FreeLibrary(hUser32);
  465. }
  466. #endif /* WINVER >= 0x0500 */
  467. return dwRes;
  468. } // SetLTRComboBox
  469. ///////////////////////////////////////////////////////////////////////////////////////
  470. // Function:
  471. // StrHasRTLChar
  472. //
  473. // Purpose:
  474. // Determine if the string has RTL characters
  475. //
  476. // Params:
  477. // pStr - string to analize
  478. //
  479. // Return Value:
  480. // TRUE if the string has RTL characters
  481. // FALSE otherwise
  482. ///////////////////////////////////////////////////////////////////////////////////////
  483. BOOL
  484. StrHasRTLChar(
  485. LCID Locale,
  486. LPCTSTR pStr
  487. )
  488. {
  489. BOOL bRTL = FALSE;
  490. DWORD dw;
  491. WORD* pwStrData = NULL;
  492. DWORD dwStrLen = 0;
  493. DEBUG_FUNCTION_NAME(TEXT("StrHasRTLChar"));
  494. if(!pStr)
  495. {
  496. DebugPrintEx(DEBUG_ERR, TEXT("pStr is NULL"));
  497. return bRTL;
  498. }
  499. dwStrLen = _tcslen(pStr);
  500. pwStrData = (WORD*)MemAlloc(sizeof(WORD) * dwStrLen);
  501. if(!pwStrData)
  502. {
  503. DebugPrintEx(DEBUG_ERR, TEXT("MemAlloc"));
  504. return bRTL;
  505. }
  506. if (!GetStringTypeEx(Locale,
  507. CT_CTYPE2,
  508. pStr,
  509. dwStrLen,
  510. pwStrData))
  511. {
  512. DebugPrintEx(DEBUG_ERR, TEXT("GetStringTypeEx() failed : %ld"), GetLastError());
  513. goto exit;
  514. }
  515. //
  516. // Looking for a character with RIGHT_TO_LEFT orientation
  517. //
  518. for (dw=0; dw < dwStrLen; ++dw)
  519. {
  520. if (C2_RIGHTTOLEFT == pwStrData[dw])
  521. {
  522. bRTL = TRUE;
  523. break;
  524. }
  525. }
  526. exit:
  527. MemFree(pwStrData);
  528. return bRTL;
  529. } // StrHasRTLChar
  530. ///////////////////////////////////////////////////////////////////////////////////////
  531. // Function:
  532. // AlignedMessageBox
  533. //
  534. // Purpose:
  535. // Display message box with correct reading order and alignment
  536. //
  537. // Params:
  538. // pStr - string to analize
  539. //
  540. // Return Value:
  541. // MessageBox() return value
  542. //
  543. ///////////////////////////////////////////////////////////////////////////////////////
  544. int
  545. AlignedMessageBox(
  546. HWND hWnd, // handle to owner window
  547. LPCTSTR lpText, // text in message box
  548. LPCTSTR lpCaption, // message box title
  549. UINT uType // message box style
  550. )
  551. {
  552. int nRes = 0;
  553. if(IsRTLUILanguage())
  554. {
  555. uType |= MB_RTLREADING | MB_RIGHT;
  556. }
  557. nRes = MessageBox(hWnd, lpText, lpCaption, uType);
  558. return nRes;
  559. }
  560. ///////////////////////////////////////////////////////////////////////////////////////
  561. // Function:
  562. // FaxTimeFormat
  563. //
  564. // Purpose:
  565. // Format time string with correct reading order
  566. //
  567. // Params:
  568. // see GetTimeFormat() parameters
  569. //
  570. // Return Value:
  571. // GetTimeFormat() return value
  572. //
  573. ///////////////////////////////////////////////////////////////////////////////////////
  574. int
  575. FaxTimeFormat(
  576. LCID Locale, // locale
  577. DWORD dwFlags, // options
  578. CONST SYSTEMTIME *lpTime, // time
  579. LPCTSTR lpFormat, // time format string
  580. LPTSTR lpTimeStr, // formatted string buffer
  581. int cchTime // size of string buffer
  582. )
  583. {
  584. int nRes = 0;
  585. TCHAR szTime[MAX_PATH];
  586. nRes = GetTimeFormat(Locale, dwFlags, lpTime, lpFormat, szTime, min(cchTime, MAX_PATH));
  587. if(0 == nRes)
  588. {
  589. return nRes;
  590. }
  591. if(0 == cchTime)
  592. {
  593. return ++nRes;
  594. }
  595. if(IsRTLLanguageInstalled())
  596. {
  597. if(StrHasRTLChar(Locale, szTime))
  598. {
  599. _sntprintf(lpTimeStr, cchTime -1, TEXT("%c%s"), UNICODE_RLM, szTime);
  600. }
  601. else
  602. {
  603. _sntprintf(lpTimeStr, cchTime -1, TEXT("%c%s"), UNICODE_LRM, szTime);
  604. }
  605. lpTimeStr[cchTime -1] = _T('\0');
  606. }
  607. else
  608. {
  609. _tcsncpy(lpTimeStr, szTime, cchTime);
  610. }
  611. return nRes;
  612. } // FaxTimeFormat
  613. ///////////////////////////////////////////////////////////////////////////////////////
  614. // Function:
  615. // IsRTLLanguageInstalled
  616. //
  617. // Purpose:
  618. // Determine if RTL Language Group is Installed
  619. //
  620. // Return Value:
  621. // TRUE if RTL Language Group is Installed
  622. // FALSE otherwise
  623. ///////////////////////////////////////////////////////////////////////////////////////
  624. BOOL
  625. IsRTLLanguageInstalled()
  626. {
  627. #if(WINVER >= 0x0500)
  628. if(MyIsValidLanguageGroup(LGRPID_ARABIC, LGRPID_INSTALLED) ||
  629. MyIsValidLanguageGroup(LGRPID_HEBREW, LGRPID_INSTALLED))
  630. {
  631. return TRUE;
  632. }
  633. else
  634. {
  635. return FALSE;
  636. }
  637. #endif /* WINVER >= 0x0500 */
  638. return FALSE;
  639. } // IsRTLLanguageInstalled
  640. ///////////////////////////////////////////////////////////////////////////////////////
  641. // Function:
  642. // SetRTLProcessLayout
  643. //
  644. // Purpose:
  645. // Set the default process layout to right-to-left
  646. //
  647. // Return Value:
  648. // Error code
  649. ///////////////////////////////////////////////////////////////////////////////////////
  650. DWORD
  651. SetRTLProcessLayout()
  652. {
  653. DWORD dwRes = ERROR_SUCCESS;
  654. #if(WINVER >= 0x0500)
  655. HMODULE hUser32 = NULL;
  656. BOOL (*pfSetProcessDefaultLayout)(DWORD);
  657. DEBUG_FUNCTION_NAME(TEXT("SetRTLProcessLayout"));
  658. if((LOBYTE(LOWORD(GetVersion()))) < 5)
  659. {
  660. //
  661. // OS version less then Windows 2000
  662. // SetProcessDefaultLayout() requires Windows 2000 or later
  663. //
  664. return ERROR_CALL_NOT_IMPLEMENTED;
  665. }
  666. hUser32 = LoadLibrary(TEXT("user32.dll"));
  667. if(!hUser32)
  668. {
  669. dwRes = GetLastError();
  670. DebugPrintEx(DEBUG_ERR,TEXT("LoadLibrary(user32.dll) failed with %ld."),dwRes);
  671. goto exit;
  672. }
  673. (FARPROC&)pfSetProcessDefaultLayout = GetProcAddress(hUser32, "SetProcessDefaultLayout");
  674. if(!pfSetProcessDefaultLayout)
  675. {
  676. dwRes = GetLastError();
  677. DebugPrintEx(DEBUG_ERR,TEXT("GetProcAddress(SetProcessDefaultLayout) failed with %ld."),dwRes);
  678. goto exit;
  679. }
  680. if(!pfSetProcessDefaultLayout(LAYOUT_RTL))
  681. {
  682. dwRes = GetLastError();
  683. DebugPrintEx(DEBUG_ERR,TEXT("SetProcessDefaultLayout failed with %ld."),dwRes);
  684. goto exit;
  685. }
  686. exit:
  687. if(hUser32)
  688. {
  689. FreeLibrary(hUser32);
  690. }
  691. #endif /* WINVER >= 0x0500 */
  692. return dwRes;
  693. }