void SMBrushSculpt::StartStroke(int mode,BOOL cont, int subobj, const SMHit &hit) { SM_ASSERT(m_stroking==FALSE); SM_ASSERT(subobj==SM_SO_VERTEX || subobj==SM_SO_EDGE || subobj==SM_SO_FACE); // undo/redo // create restore object DbgAssert(!m_actrestore); m_actrestore = new MeshVertRestore(m_SM->m_polyobj); // and make it active DbgAssert(!theHold.Holding()); if (0 && theHold.Holding()) { theHold.Cancel(); } theHold.Begin(); if (theHold.Holding()){ theHold.Put (m_actrestore); } // start the stroke m_stroking = TRUE; m_subobj = subobj; }
FARPROC SMDLLModule::GetProcAddress(const char* pszProcName) { SM_ASSERT(pszProcName); SM_ASSERT(hModule); if(!pszProcName) throw SMRuntimeException("Wrong parameter !"); return ::GetProcAddress(hModule, pszProcName); }
void SMNetworkAdapterSettings::SetField(const SMString& fieldname, const SMString& value) const { HDEVINFO devInfo = NULL; SP_DEVINFO_DATA devInfoData = {0}; try { _FingSetupInfo(&devInfo, &devInfoData); SMRegistryKey netDeviceKey; SMRegistryKey advancedSettingsKey; _FindAdvancedSettings(&devInfo, &devInfoData, &netDeviceKey, &advancedSettingsKey); ////////////////////////////////////////////////////////////////////////// // Set field to a new value DWORD dwFieldType = netDeviceKey.GetType(fieldname); if( -1 != dwFieldType) { switch (dwFieldType) { case REG_SZ: { HRESULT hr = netDeviceKey.SetString(fieldname, value); SM_ASSERT(SUCCEEDED(hr)); hr = hr; }break; case REG_DWORD: { HRESULT hr = netDeviceKey.SetDword(fieldname, value.IntValue()); SM_ASSERT(SUCCEEDED(hr)); hr = hr; }break; default: SM_ASSERT(false); break; } } } catch (const SMRuntimeException& e) { SM_LOG(S_FALSE, SMTRACE, __FUNCTION__ << " Exception: " << e.what()); throw; } }
void SMNetworkAdapterSettings::_FingSetupInfo(HDEVINFO* devInfo, SP_DEVINFO_DATA* devInfoData) const { SM_ASSERT( !_hardwareId.IsEmpty() ); SMString hwID(_hardwareId); hwID.MakeUpper(); *devInfo = ::SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT); if( INVALID_HANDLE_VALUE == *devInfo ) throw SMRuntimeException(::GetLastError()); ::ZeroMemory(devInfoData, sizeof(SP_DEVINFO_DATA)); devInfoData->cbSize = sizeof(SP_DEVINFO_DATA); PTSTR buf = NULL; DWORD bufSize = 0; DWORD reqSize = 0; for(int i=0; SetupDiEnumDeviceInfo(*devInfo,i, devInfoData); i++) { if ( !SetupDiGetDeviceInstanceId(*devInfo, devInfoData, buf, bufSize, &reqSize) ) { if ( bufSize < reqSize ) { if ( NULL != buf ) { delete[] buf; buf = NULL; bufSize = 0; } buf = new TCHAR[reqSize]; if ( NULL == buf ) { SM_LOG(1, E_FAIL, SMString("Insufficient memory : ") + _com_error(GetLastError()).ErrorMessage()); break; } bufSize = reqSize; if ( !SetupDiGetDeviceInstanceId(*devInfo, devInfoData, buf, bufSize, &reqSize) ) throw SMRuntimeException(::GetLastError()); } else { SM_LOG(1, E_FAIL, SMString("SetupDiGetDeviceInstanceId(): ") + _com_error(GetLastError()).ErrorMessage()); break; } } SMString szBuf = buf; szBuf.MakeUpper(); if ( szBuf.Find(hwID.DataW()) != -1 ) return; } }
SMString SMNetworkAdapterSettings::GetField(const SMString& fieldname) const { SMString sResult = ""; try { HDEVINFO devInfo = NULL; SP_DEVINFO_DATA devInfoData = {0}; _FingSetupInfo(&devInfo, &devInfoData); SMRegistryKey netDeviceKey; SMRegistryKey advancedSettingsKey; _FindAdvancedSettings(&devInfo, &devInfoData, &netDeviceKey, &advancedSettingsKey); ////////////////////////////////////////////////////////////////////////// // Set field to a new value DWORD dwFieldType = netDeviceKey.GetType(fieldname); if( -1 != dwFieldType) { switch (dwFieldType) { case REG_SZ: { sResult = netDeviceKey.GetString(fieldname); }break; case REG_DWORD: { DWORD value = netDeviceKey.GetDword(fieldname); sResult.Format("%d", value); }break; default: SM_ASSERT(false); break; } } } catch (const SMRuntimeException& e) { SM_LOG(S_FALSE, SMTRACE, __FUNCTION__ << " Exception: " << e.what()); throw; } return sResult; }
void SMNetworkAdapterSettings::_EnumerateAdvancedSettings(SMRegistryKey& netDeviceKey, SMRegistryKey& advancedSettingsKey, INetworkAdapterSettingsCallback* pCallback) const { SMString key; DWORD valueIndex = 0; while (advancedSettingsKey.EnumKey( valueIndex++, key)) { SMRegistryKey particularSetting; HRESULT hrParticularKey = particularSetting.Open(advancedSettingsKey, key); if(FAILED(hrParticularKey)) { SM_LOG(E_FAIL, SMTRACE, __FUNCTION__ << "Failed open particular setting's key. Setting \"" << key << "\" will be missed. \n"); continue; } SMString settingDescription = particularSetting.GetString(PARAM_DESCRIPTION); DWORD dwValueType = netDeviceKey.GetType(key); if( -1 != dwValueType) { switch (dwValueType) { case REG_SZ: { SMString sValue = netDeviceKey.GetString(key); pCallback->OnAdvancedSetting(key, settingDescription, sValue); }break; case REG_DWORD: { DWORD dwValue = netDeviceKey.GetDword(key); pCallback->OnAdvancedSetting(key, settingDescription, dwValue); }break; default: SM_ASSERT(false); break; } } else SM_LOG(E_FAIL, SMTRACE, __FUNCTION__ << "Failed retrieve type of a registry field. \n"); } }