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.

157 lines
5.6 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: common.h
  4. //
  5. // Module: CMSTP.EXE
  6. //
  7. // Synopsis: This header contains common functions used for the different
  8. // aspects of the profile installer (install, uninstall, migration).
  9. //
  10. // Copyright (c) 1997-1999 Microsoft Corporation
  11. //
  12. // Author: quintinb Created Header 07/14/98
  13. //
  14. //+----------------------------------------------------------------------------
  15. #ifndef _CMSTP_COMMON_H
  16. #define _CMSTP_COMMON_H
  17. #define _MBCS
  18. //
  19. // Standard Windows Includes
  20. //
  21. #include <windows.h>
  22. #include <ras.h>
  23. #include <raserror.h>
  24. #include <shlobj.h>
  25. #include <shellapi.h>
  26. //#include <objbase.h>
  27. //
  28. // Our own includes
  29. //
  30. #include "cmdebug.h"
  31. #include "resource.h"
  32. #include "cmsetup.h"
  33. #include "dynamiclib.h"
  34. #include "cmras.h"
  35. #include "mutex.h"
  36. //#include "pidlutil.h"
  37. //#include "netcon.h"
  38. //#include "netconp.h"
  39. //#include "cfpidl.h"
  40. #include "loadconnfolder.h"
  41. #include "base_str.h"
  42. #include "mgr_str.h"
  43. #include "inf_str.h"
  44. #include "ras_str.h"
  45. #include "stp_str.h"
  46. #include "reg_str.h"
  47. #include "userinfo_str.h"
  48. #include "ver_str.h"
  49. //
  50. // Type Definitions
  51. //
  52. typedef DWORD (WINAPI *pfnRasSetEntryPropertiesSpec)(LPCTSTR, LPCTSTR, LPRASENTRY, DWORD, LPBYTE, DWORD);
  53. typedef DWORD (WINAPI *pfnRasGetEntryPropertiesSpec)(LPCTSTR, LPCTSTR, LPRASENTRY, LPDWORD, LPBYTE, LPDWORD);
  54. typedef DWORD (WINAPI *pfnRasDeleteEntrySpec)(LPCTSTR, LPCTSTR);
  55. typedef DWORD (WINAPI *pfnRasEnumEntriesSpec)(LPTSTR, LPTSTR, LPRASENTRYNAME, LPDWORD, LPDWORD);
  56. typedef DWORD (WINAPI *pfnRasEnumDevicesSpec)(LPRASDEVINFO, LPDWORD, LPDWORD);
  57. typedef DWORD (WINAPI *pfnRasSetCredentialsSpec)(LPCSTR, LPCSTR, LPRASCREDENTIALSA, BOOL);
  58. typedef DWORD (WINAPI *pfnSHGetFolderPathSpec)(HWND, int, HANDLE, DWORD, LPTSTR);
  59. typedef HRESULT (WINAPI *pfnLaunchConnectionSpec)(const GUID&);
  60. typedef HRESULT (WINAPI *pfnCreateShortcutSpec)(const GUID&, WCHAR*);
  61. typedef HRESULT (WINAPI *pfnLaunchConnectionExSpec)(DWORD, const GUID&);
  62. typedef DWORD (WINAPI *pfnSHGetSpecialFolderPathWSpec)(HWND, WCHAR*, int, BOOL);
  63. typedef struct _InitDialogStruct
  64. {
  65. LPTSTR pszTitle;
  66. BOOL bNoDesktopIcon;
  67. BOOL bSingleUser;
  68. } InitDialogStruct;
  69. //
  70. // Constants
  71. //
  72. const TCHAR* const c_pszRegNameSpace = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\Desktop\\NameSpace");
  73. const TCHAR* const c_pszRegUninstall = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
  74. const TCHAR* const c_pszProfileInstallPath = TEXT("ProfileInstallPath");
  75. const TCHAR* const c_pszRegStickyUiDefault = TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Network\\Network Connections");
  76. const TCHAR* const c_pszRegDesktopShortCut = TEXT("DesktopShortcut");
  77. const int ALLUSERS = 0x1;
  78. const int CREATEDESKTOPICON = 0x10;
  79. typedef struct _PresharedKeyPINStruct
  80. {
  81. TCHAR szPIN[c_dwMaxPresharedKeyPIN + 1];
  82. } PresharedKeyPINStruct;
  83. //
  84. // Internal Functions (Used by other functions in the file)
  85. //
  86. void DeleteNT5ShortcutFromPathAndNameW(HINSTANCE hInstance, LPCWSTR szwProfileName, int nFolder);
  87. void DeleteNT5ShortcutFromPathAndNameA(HINSTANCE hInstance, LPCSTR szProfileName, int nFolder);
  88. //
  89. // Functions
  90. //
  91. BOOL RemovePhonebookEntry(LPCTSTR pszEntryName, LPTSTR pszPhonebook, BOOL bMatchSimilarEntries);
  92. BOOL RemoveSpecificPhoneBookEntry(LPCTSTR szLongServiceName, LPTSTR pszPhonebook);
  93. HRESULT CreateNT5ProfileShortcut(LPCTSTR pszProfileName, LPCTSTR pszPhoneBook, BOOL bAllUsers);
  94. BOOL WriteCmPhonebookEntry(LPCTSTR szLongServiceName, LPCTSTR szFullPathtoPBK, LPCTSTR pszCmsFile);
  95. BOOL GetRasModems(LPRASDEVINFO *pprdiRasDevInfo, LPDWORD pdwCnt);
  96. BOOL PickModem(LPTSTR pszDeviceType, LPTSTR pszDeviceName, BOOL fUseVpnDevice);
  97. BOOL IsAdmin(void);
  98. BOOL IsAuthenticatedUser(void);
  99. HRESULT HrIsCMProfilePrivate(LPCTSTR szPhonebook);
  100. HRESULT GetNT5FolderPath(int nFolder, OUT LPTSTR lpszPath);
  101. void RefreshDesktop(void);
  102. BOOL GetAllUsersCmDir(LPTSTR pszDir, HINSTANCE hInstance);
  103. LPTSTR GetPrivateCmUserDir(LPTSTR pszDir, HINSTANCE hInstance);
  104. HRESULT HrRegDeleteKeyTree (HKEY hkeyParent, LPCTSTR szRemoveKey);
  105. HRESULT LaunchProfile(LPCTSTR pszFullPathToCmpFile, LPCTSTR pszServiceName,
  106. LPCTSTR pszPhoneBook, BOOL bInstallForAllUsers);
  107. BOOL AllUserProfilesInstalled();
  108. BOOL GetPhoneBookPath(LPCTSTR pszInstallDir, LPTSTR* ppszPhoneBook, BOOL fAllUser);
  109. void RemoveShowIconFromRunPostSetupCommands(LPCTSTR szInfFile);
  110. BOOL GetHiddenPhoneBookPath(LPCTSTR pszProfileDir, LPTSTR* ppszPhonebook);
  111. BOOL GetRasApis(pfnRasDeleteEntrySpec* pRasDeleteEntry, pfnRasEnumEntriesSpec* pRasEnumEntries,
  112. pfnRasSetEntryPropertiesSpec* pRasSetEntryProperties,
  113. pfnRasEnumDevicesSpec* pRasEnumDevices, pfnRasGetEntryPropertiesSpec* pRasGetEntryProperties,
  114. pfnRasSetCredentialsSpec* pRasSetCredentials);
  115. BOOL GetShell32Apis(pfnSHGetFolderPathSpec* pGetFolderPath,
  116. pfnSHGetSpecialFolderPathWSpec* pGetSpecialFolderPathW);
  117. BOOL GetNetShellApis(pfnLaunchConnectionSpec* pLaunchConnection,
  118. pfnCreateShortcutSpec* pCreateShortcut,
  119. pfnLaunchConnectionExSpec* pLaunchConnectionEx);
  120. //
  121. // Defines
  122. //
  123. #ifdef UNICODE
  124. #define DeleteNT5ShortcutFromPathAndName DeleteNT5ShortcutFromPathAndNameW
  125. #else
  126. #define DeleteNT5ShortcutFromPathAndName DeleteNT5ShortcutFromPathAndNameA
  127. #endif
  128. //
  129. // Externs -- these are defined in cmstp.cpp and allow us to use EnsureRasDllsLoaded and
  130. // EnsureShell32Loaded so that we only load the Ras Dll's and Shell32 once per
  131. // run of the exe.
  132. //
  133. extern CDynamicLibrary* g_pRasApi32;
  134. extern CDynamicLibrary* g_pRnaph;
  135. extern CDynamicLibrary* g_pShell32;
  136. extern CDynamicLibrary* g_pNetShell;
  137. #endif //_CMSTP_COMMON_H