Spremenil sem odstranitev profilov WLAN, da ne uporablja več preimenovanja ampak izvoz. Ker preimenovanje ni delovalo (vsaj na Win7). Zanimivo: preimenovanje ne deluje niti v uporabniškem vmesniku Network and Sharing Center.
This commit is contained in:
parent
bb5ec43fc9
commit
2d0a99755f
@ -573,7 +573,7 @@ UINT MSICA_API EvaluateWLANProfiles(MSIHANDLE hInstall)
|
|||||||
for (i = 0; i < pInterfaceList->dwNumberOfItems; i++) {
|
for (i = 0; i < pInterfaceList->dwNumberOfItems; i++) {
|
||||||
// Check for not ready state in interface.
|
// Check for not ready state in interface.
|
||||||
if (pInterfaceList->InterfaceInfo[i].isState != wlan_interface_state_not_ready) {
|
if (pInterfaceList->InterfaceInfo[i].isState != wlan_interface_state_not_ready) {
|
||||||
olExecuteInstall.AddTail(new MSICA::COpWLANProfileSet(pInterfaceList->InterfaceInfo[i].InterfaceGuid, sName, sProfileXML, MSICA_WLAN_PROFILE_TICK_SIZE));
|
olExecuteInstall.AddTail(new MSICA::COpWLANProfileSet(pInterfaceList->InterfaceInfo[i].InterfaceGuid, 0, sName, sProfileXML, MSICA_WLAN_PROFILE_TICK_SIZE));
|
||||||
iTick += MSICA_WLAN_PROFILE_TICK_SIZE;
|
iTick += MSICA_WLAN_PROFILE_TICK_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ UINT MSICA_API EvaluateWLANProfiles(MSIHANDLE hInstall)
|
|||||||
|
|
||||||
UINT MSICA_API ExecuteSequence(MSIHANDLE hInstall)
|
UINT MSICA_API ExecuteSequence(MSIHANDLE hInstall)
|
||||||
{
|
{
|
||||||
//::MessageBox(NULL, _T(__FUNCTION__), _T("MSICA"), MB_OK);
|
::MessageBox(NULL, _T(__FUNCTION__), _T("MSICA"), MB_OK);
|
||||||
|
|
||||||
return MSICA::ExecuteSequence(hInstall);
|
return MSICA::ExecuteSequence(hInstall);
|
||||||
}
|
}
|
||||||
|
@ -553,24 +553,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// COpWLANProfileRename
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class COpWLANProfileRename : public COpWLANProfile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
COpWLANProfileRename(const GUID &guidInterface = GUID_NULL, LPCWSTR pszProfileNameSrc = L"", LPCWSTR pszProfileNameDst = L"", int iTicks = 0);
|
|
||||||
virtual HRESULT Execute(CSession *pSession);
|
|
||||||
|
|
||||||
friend inline HRESULT operator <<(ATL::CAtlFile &f, const COpWLANProfileRename &op);
|
|
||||||
friend inline HRESULT operator >>(ATL::CAtlFile &f, COpWLANProfileRename &op);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ATL::CAtlStringW m_sProfileNameDst;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// COpWLANProfileSet
|
// COpWLANProfileSet
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -578,13 +560,14 @@ protected:
|
|||||||
class COpWLANProfileSet : public COpWLANProfile
|
class COpWLANProfileSet : public COpWLANProfile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COpWLANProfileSet(const GUID &guidInterface = GUID_NULL, LPCWSTR pszProfileName = L"", LPCWSTR pszProfileXML = L"", int iTicks = 0);
|
COpWLANProfileSet(const GUID &guidInterface = GUID_NULL, DWORD dwFlags = 0, LPCWSTR pszProfileName = L"", LPCWSTR pszProfileXML = L"", int iTicks = 0);
|
||||||
virtual HRESULT Execute(CSession *pSession);
|
virtual HRESULT Execute(CSession *pSession);
|
||||||
|
|
||||||
friend inline HRESULT operator <<(ATL::CAtlFile &f, const COpWLANProfileSet &op);
|
friend inline HRESULT operator <<(ATL::CAtlFile &f, const COpWLANProfileSet &op);
|
||||||
friend inline HRESULT operator >>(ATL::CAtlFile &f, COpWLANProfileSet &op);
|
friend inline HRESULT operator >>(ATL::CAtlFile &f, COpWLANProfileSet &op);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
DWORD m_dwFlags;
|
||||||
ATL::CAtlStringW m_sProfileXML;
|
ATL::CAtlStringW m_sProfileXML;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -628,7 +611,6 @@ protected:
|
|||||||
OP_SVC_START,
|
OP_SVC_START,
|
||||||
OP_SVC_STOP,
|
OP_SVC_STOP,
|
||||||
OP_WLAN_PROFILE_DELETE,
|
OP_WLAN_PROFILE_DELETE,
|
||||||
OP_WLAN_PROFILE_RENAME,
|
|
||||||
OP_WLAN_PROFILE_SET,
|
OP_WLAN_PROFILE_SET,
|
||||||
OP_SUBLIST
|
OP_SUBLIST
|
||||||
};
|
};
|
||||||
@ -1621,33 +1603,12 @@ inline HRESULT operator >>(ATL::CAtlFile &f, COpWLANProfile &op)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline HRESULT operator <<(ATL::CAtlFile &f, const COpWLANProfileRename &op)
|
|
||||||
{
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
hr = f << (const COpWLANProfile&)op; if (FAILED(hr)) return hr;
|
|
||||||
hr = f << op.m_sProfileNameDst; if (FAILED(hr)) return hr;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline HRESULT operator >>(ATL::CAtlFile &f, COpWLANProfileRename &op)
|
|
||||||
{
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
hr = f >> (COpWLANProfile&)op; if (FAILED(hr)) return hr;
|
|
||||||
hr = f >> op.m_sProfileNameDst; if (FAILED(hr)) return hr;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline HRESULT operator <<(ATL::CAtlFile &f, const COpWLANProfileSet &op)
|
inline HRESULT operator <<(ATL::CAtlFile &f, const COpWLANProfileSet &op)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = f << (const COpWLANProfile&)op; if (FAILED(hr)) return hr;
|
hr = f << (const COpWLANProfile&)op; if (FAILED(hr)) return hr;
|
||||||
|
hr = f << (int)(op.m_dwFlags); if (FAILED(hr)) return hr;
|
||||||
hr = f << op.m_sProfileXML; if (FAILED(hr)) return hr;
|
hr = f << op.m_sProfileXML; if (FAILED(hr)) return hr;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@ -1658,8 +1619,9 @@ inline HRESULT operator >>(ATL::CAtlFile &f, COpWLANProfileSet &op)
|
|||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = f >> (COpWLANProfile&)op; if (FAILED(hr)) return hr;
|
hr = f >> (COpWLANProfile&)op; if (FAILED(hr)) return hr;
|
||||||
hr = f >> op.m_sProfileXML; if (FAILED(hr)) return hr;
|
hr = f >> (int&)(op.m_dwFlags); if (FAILED(hr)) return hr;
|
||||||
|
hr = f >> op.m_sProfileXML; if (FAILED(hr)) return hr;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@ -1697,7 +1659,6 @@ inline HRESULT operator <<(ATL::CAtlFile &f, const COpList &list)
|
|||||||
else if (dynamic_cast<const COpSvcStart* >(pOp)) hr = list.Save<COpSvcStart, COpList::OP_SVC_START >(f, pOp);
|
else if (dynamic_cast<const COpSvcStart* >(pOp)) hr = list.Save<COpSvcStart, COpList::OP_SVC_START >(f, pOp);
|
||||||
else if (dynamic_cast<const COpSvcStop* >(pOp)) hr = list.Save<COpSvcStop, COpList::OP_SVC_STOP >(f, pOp);
|
else if (dynamic_cast<const COpSvcStop* >(pOp)) hr = list.Save<COpSvcStop, COpList::OP_SVC_STOP >(f, pOp);
|
||||||
else if (dynamic_cast<const COpWLANProfileDelete*>(pOp)) hr = list.Save<COpWLANProfileDelete, COpList::OP_WLAN_PROFILE_DELETE>(f, pOp);
|
else if (dynamic_cast<const COpWLANProfileDelete*>(pOp)) hr = list.Save<COpWLANProfileDelete, COpList::OP_WLAN_PROFILE_DELETE>(f, pOp);
|
||||||
else if (dynamic_cast<const COpWLANProfileRename*>(pOp)) hr = list.Save<COpWLANProfileRename, COpList::OP_WLAN_PROFILE_RENAME>(f, pOp);
|
|
||||||
else if (dynamic_cast<const COpWLANProfileSet* >(pOp)) hr = list.Save<COpWLANProfileSet, COpList::OP_WLAN_PROFILE_SET >(f, pOp);
|
else if (dynamic_cast<const COpWLANProfileSet* >(pOp)) hr = list.Save<COpWLANProfileSet, COpList::OP_WLAN_PROFILE_SET >(f, pOp);
|
||||||
else if (dynamic_cast<const COpList* >(pOp)) hr = list.Save<COpList, COpList::OP_SUBLIST >(f, pOp);
|
else if (dynamic_cast<const COpList* >(pOp)) hr = list.Save<COpList, COpList::OP_SUBLIST >(f, pOp);
|
||||||
else {
|
else {
|
||||||
@ -1749,7 +1710,6 @@ inline HRESULT operator >>(ATL::CAtlFile &f, COpList &list)
|
|||||||
case COpList::OP_SVC_START: hr = list.LoadAndAddTail<COpSvcStart >(f); break;
|
case COpList::OP_SVC_START: hr = list.LoadAndAddTail<COpSvcStart >(f); break;
|
||||||
case COpList::OP_SVC_STOP: hr = list.LoadAndAddTail<COpSvcStop >(f); break;
|
case COpList::OP_SVC_STOP: hr = list.LoadAndAddTail<COpSvcStop >(f); break;
|
||||||
case COpList::OP_WLAN_PROFILE_DELETE: hr = list.LoadAndAddTail<COpWLANProfileDelete>(f); break;
|
case COpList::OP_WLAN_PROFILE_DELETE: hr = list.LoadAndAddTail<COpWLANProfileDelete>(f); break;
|
||||||
case COpList::OP_WLAN_PROFILE_RENAME: hr = list.LoadAndAddTail<COpWLANProfileRename>(f); break;
|
|
||||||
case COpList::OP_WLAN_PROFILE_SET: hr = list.LoadAndAddTail<COpWLANProfileSet >(f); break;
|
case COpList::OP_WLAN_PROFILE_SET: hr = list.LoadAndAddTail<COpWLANProfileSet >(f); break;
|
||||||
case COpList::OP_SUBLIST: hr = list.LoadAndAddTail<COpList >(f); break;
|
case COpList::OP_SUBLIST: hr = list.LoadAndAddTail<COpList >(f); break;
|
||||||
default:
|
default:
|
||||||
|
@ -33,20 +33,19 @@ HRESULT COpWLANProfileDelete::Execute(CSession *pSession)
|
|||||||
dwError = ::WlanOpenHandle(2, NULL, &dwNegotiatedVersion, &hClientHandle);
|
dwError = ::WlanOpenHandle(2, NULL, &dwNegotiatedVersion, &hClientHandle);
|
||||||
if (dwError == NO_ERROR) {
|
if (dwError == NO_ERROR) {
|
||||||
if (pSession->m_bRollbackEnabled) {
|
if (pSession->m_bRollbackEnabled) {
|
||||||
ATL::CAtlStringW sBackupName;
|
LPWSTR pszProfileXML = NULL;
|
||||||
UINT uiCount = 0;
|
DWORD dwFlags = 0, dwGrantedAccess = 0;
|
||||||
|
|
||||||
do {
|
// Get profile settings as XML first.
|
||||||
// Rename the profile to make a backup.
|
dwError = ::WlanGetProfile(hClientHandle, &m_guidInterface, m_sValue, NULL, &pszProfileXML, &dwFlags, &dwGrantedAccess);
|
||||||
sBackupName.Format(L"%ls (orig %u)", (LPCWSTR)m_sValue, ++uiCount);
|
|
||||||
dwError = ::WlanRenameProfile(hClientHandle, &m_guidInterface, m_sValue, sBackupName, NULL);
|
|
||||||
} while (dwError == ERROR_ALREADY_EXISTS);
|
|
||||||
if (dwError == NO_ERROR) {
|
if (dwError == NO_ERROR) {
|
||||||
// Order rollback action to restore from backup copy.
|
// Delete the profile.
|
||||||
pSession->m_olRollback.AddHead(new COpWLANProfileRename(m_guidInterface, sBackupName, m_sValue));
|
dwError = ::WlanDeleteProfile(hClientHandle, &m_guidInterface, m_sValue, NULL);
|
||||||
|
if (dwError == NO_ERROR) {
|
||||||
// Order commit action to delete backup copy.
|
// Order rollback action to recreate it.
|
||||||
pSession->m_olCommit.AddTail(new COpWLANProfileDelete(m_guidInterface, sBackupName));
|
pSession->m_olRollback.AddHead(new COpWLANProfileSet(m_guidInterface, dwFlags, m_sValue, pszProfileXML));
|
||||||
|
}
|
||||||
|
::WlanFreeMemory(pszProfileXML);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Delete the profile.
|
// Delete the profile.
|
||||||
@ -71,56 +70,13 @@ HRESULT COpWLANProfileDelete::Execute(CSession *pSession)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// COpWLANProfileRename
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
COpWLANProfileRename::COpWLANProfileRename(const GUID &guidInterface, LPCWSTR pszProfileNameSrc, LPCWSTR pszProfileNameDst, int iTicks) :
|
|
||||||
COpWLANProfile(guidInterface, pszProfileNameSrc, iTicks),
|
|
||||||
m_sProfileNameDst(pszProfileNameDst)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT COpWLANProfileRename::Execute(CSession *pSession)
|
|
||||||
{
|
|
||||||
DWORD dwError, dwNegotiatedVersion;
|
|
||||||
HANDLE hClientHandle;
|
|
||||||
|
|
||||||
dwError = ::WlanOpenHandle(2, NULL, &dwNegotiatedVersion, &hClientHandle);
|
|
||||||
if (dwError == NO_ERROR) {
|
|
||||||
// Rename the profile.
|
|
||||||
dwError = ::WlanRenameProfile(hClientHandle, &m_guidInterface, m_sValue, m_sProfileNameDst, NULL);
|
|
||||||
if (dwError == NO_ERROR && pSession->m_bRollbackEnabled) {
|
|
||||||
// Order rollback action to rename it back.
|
|
||||||
pSession->m_olRollback.AddHead(new COpWLANProfileRename(m_guidInterface, m_sProfileNameDst, m_sValue));
|
|
||||||
}
|
|
||||||
::WlanCloseHandle(hClientHandle, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dwError == NO_ERROR)
|
|
||||||
return S_OK;
|
|
||||||
else {
|
|
||||||
PMSIHANDLE hRecordProg = ::MsiCreateRecord(5);
|
|
||||||
ATL::CAtlStringW sGUID;
|
|
||||||
GuidToString(m_guidInterface, sGUID);
|
|
||||||
::MsiRecordSetInteger(hRecordProg, 1, ERROR_INSTALL_WLAN_PROFILE_RENAME);
|
|
||||||
::MsiRecordSetStringW(hRecordProg, 2, sGUID );
|
|
||||||
::MsiRecordSetStringW(hRecordProg, 3, m_sValue );
|
|
||||||
::MsiRecordSetStringW(hRecordProg, 4, m_sProfileNameDst );
|
|
||||||
::MsiRecordSetInteger(hRecordProg, 5, dwError );
|
|
||||||
::MsiProcessMessage(pSession->m_hInstall, INSTALLMESSAGE_ERROR, hRecordProg);
|
|
||||||
return AtlHresultFromWin32(dwError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// COpWLANProfileSet
|
// COpWLANProfileSet
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
COpWLANProfileSet::COpWLANProfileSet(const GUID &guidInterface, LPCWSTR pszProfileName, LPCWSTR pszProfileXML, int iTicks) :
|
COpWLANProfileSet::COpWLANProfileSet(const GUID &guidInterface, DWORD dwFlags, LPCWSTR pszProfileName, LPCWSTR pszProfileXML, int iTicks) :
|
||||||
COpWLANProfile(guidInterface, pszProfileName, iTicks),
|
COpWLANProfile(guidInterface, pszProfileName, iTicks),
|
||||||
|
m_dwFlags(dwFlags),
|
||||||
m_sProfileXML(pszProfileXML)
|
m_sProfileXML(pszProfileXML)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -144,7 +100,7 @@ HRESULT COpWLANProfileSet::Execute(CSession *pSession)
|
|||||||
dwError = ::WlanOpenHandle(2, NULL, &dwNegotiatedVersion, &hClientHandle);
|
dwError = ::WlanOpenHandle(2, NULL, &dwNegotiatedVersion, &hClientHandle);
|
||||||
if (dwError == NO_ERROR) {
|
if (dwError == NO_ERROR) {
|
||||||
// Set the profile.
|
// Set the profile.
|
||||||
dwError = ::WlanSetProfile(hClientHandle, &m_guidInterface, 0, m_sProfileXML, NULL, TRUE, NULL, &wlrc);
|
dwError = ::WlanSetProfile(hClientHandle, &m_guidInterface, m_dwFlags, m_sProfileXML, NULL, TRUE, NULL, &wlrc);
|
||||||
if (dwError == NO_ERROR && pSession->m_bRollbackEnabled) {
|
if (dwError == NO_ERROR && pSession->m_bRollbackEnabled) {
|
||||||
// Order rollback action to delete it.
|
// Order rollback action to delete it.
|
||||||
pSession->m_olRollback.AddHead(new COpWLANProfileDelete(m_guidInterface, m_sValue));
|
pSession->m_olRollback.AddHead(new COpWLANProfileDelete(m_guidInterface, m_sValue));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user