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.

193 lines
3.5 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <tchar.h>
  4. #include "faxutil.h"
  5. #include "faxreg.h"
  6. #include "resource.h"
  7. BOOL
  8. IsUserAdmin(
  9. VOID
  10. );
  11. BOOL
  12. GetInstallationInfo(
  13. LPDWORD Installed,
  14. LPDWORD InstallType,
  15. LPDWORD InstalledPlatforms
  16. )
  17. {
  18. HKEY hKey;
  19. LONG rVal;
  20. DWORD RegType;
  21. DWORD RegSize;
  22. if (Installed == NULL || InstallType == NULL) {
  23. return FALSE;
  24. }
  25. rVal = RegOpenKey(
  26. HKEY_LOCAL_MACHINE,
  27. REGKEY_FAX_SETUP,
  28. &hKey
  29. );
  30. if (rVal != ERROR_SUCCESS) {
  31. DebugPrint(( TEXT("Could not open setup registry key, ec=0x%08x"), rVal ));
  32. return FALSE;
  33. }
  34. RegSize = sizeof(DWORD);
  35. rVal = RegQueryValueEx(
  36. hKey,
  37. REGVAL_FAXINSTALLED,
  38. 0,
  39. &RegType,
  40. (LPBYTE) Installed,
  41. &RegSize
  42. );
  43. if (rVal != ERROR_SUCCESS) {
  44. DebugPrint(( TEXT("Could not query installed registry value, ec=0x%08x"), rVal ));
  45. *Installed = 0;
  46. }
  47. rVal = RegQueryValueEx(
  48. hKey,
  49. REGVAL_FAXINSTALL_TYPE,
  50. 0,
  51. &RegType,
  52. (LPBYTE) InstallType,
  53. &RegSize
  54. );
  55. if (rVal != ERROR_SUCCESS) {
  56. DebugPrint(( TEXT("Could not query install type registry value, ec=0x%08x"), rVal ));
  57. *InstallType = 0;
  58. }
  59. rVal = RegQueryValueEx(
  60. hKey,
  61. REGVAL_FAXINSTALLED_PLATFORMS,
  62. 0,
  63. &RegType,
  64. (LPBYTE) InstalledPlatforms,
  65. &RegSize
  66. );
  67. if (rVal != ERROR_SUCCESS) {
  68. DebugPrint(( TEXT("Could not query install platforms mask registry value, ec=0x%08x"), rVal ));
  69. *InstalledPlatforms = 0;
  70. }
  71. RegCloseKey( hKey );
  72. return TRUE;
  73. }
  74. INT
  75. wWinMain(
  76. HINSTANCE hInstance,
  77. HINSTANCE hPrevInstance,
  78. LPTSTR lpCmdLine,
  79. INT nCmdShow
  80. )
  81. /*++
  82. Routine Description:
  83. Application entry point
  84. Arguments:
  85. hInstance - Identifies the current instance of the application
  86. hPrevInstance - Identifies the previous instance of the application
  87. lpCmdLine - Specifies the command line for the application.
  88. nCmdShow - Specifies how the window is to be shown
  89. Return Value:
  90. 0
  91. --*/
  92. {
  93. DWORD Installed;
  94. DWORD InstallType;
  95. DWORD InstalledPlatforms;
  96. WCHAR Str[64];
  97. WCHAR Cmd[128];
  98. STARTUPINFO si;
  99. PROCESS_INFORMATION pi;
  100. if (!GetInstallationInfo( &Installed, &InstallType, &InstalledPlatforms )) {
  101. goto error_exit;
  102. }
  103. if (!Installed) {
  104. goto error_exit;
  105. }
  106. Str[0] = 0;
  107. if (InstallType & FAX_INSTALL_SERVER) {
  108. if (IsUserAdmin()) {
  109. LoadString( hInstance, IDS_FAX_SERVER, Str, sizeof(Str) );
  110. } else {
  111. LoadString( hInstance, IDS_FAX_CLIENT, Str, sizeof(Str) );
  112. }
  113. } else if (InstallType & FAX_INSTALL_WORKSTATION) {
  114. LoadString( hInstance, IDS_FAX_WORKSTATION, Str, sizeof(Str) );
  115. } else if (InstallType & FAX_INSTALL_NETWORK_CLIENT) {
  116. LoadString( hInstance, IDS_FAX_WORKSTATION, Str, sizeof(Str) );
  117. } else {
  118. goto error_exit;
  119. }
  120. if (!Str[0]) {
  121. goto error_exit;
  122. }
  123. swprintf( Cmd, L"rundll32 shell32.dll,Control_RunDLL faxcfg.cpl,%s", Str );
  124. GetStartupInfo( &si );
  125. if (!CreateProcess(
  126. NULL,
  127. Cmd,
  128. NULL,
  129. NULL,
  130. FALSE,
  131. 0,
  132. NULL,
  133. NULL,
  134. &si,
  135. &pi
  136. ))
  137. {
  138. goto error_exit;
  139. }
  140. return 0;
  141. error_exit:
  142. MessageBeep( MB_ICONEXCLAMATION );
  143. Sleep( 3000 );
  144. return 0;
  145. }