vc 添加HTTP mime类型
来源:互联网 发布:走出趣软件下载 编辑:程序博客网 时间:2024/06/06 05:49
long CreateMimeType(/*[in]*/ const CMimeType& objCMimeType,
/*[out]*/wstring& strErr)
{
IADs* ptrADs= 0;
HRESULT hr= S_FALSE;
CComPtr<IISMimeType>ptrMimeType=0;
_variant_t vntMimeMap;
//Reinitialise the error code
m_lError= 0;
m_wstrMethodName=L"CreateMimeType";
strErr=SUCCESS;
try
{ //Get the handle to the MimeMap
hr = ADsGetObject(L"IIS://LocalHost/MimeMap",IID_IADs,(void**) &ptrADs);
if(FAILED(hr))
{
strErr = ADS_GETOBJECT_FAILED;
throw hr;
}
hr = ptrADs->QueryInterface(IID_IISMimeType, (void **)&ptrMimeType );
if(FAILED(hr))
{
}
//Load the property MimeMap
hr = ptrADs->GetEx(L"MimeMap",&vntMimeMap);
SAFEARRAY* pArrMimeMap ;
//point the safearray to the array inside the variant..
pArrMimeMap = vntMimeMap.parray;
//*******************************************************
long lHigh;
SAFEARRAY *psa; // The safearray
SAFEARRAYBOUND rgsabound[1]; // A one dimensional array
long * pData;
long lValue, lIndex;
_variant_t vntNewMimeType;
SafeArrayGetUBound(pArrMimeMap, 1, &lHigh);
rgsabound[0].lLbound=0; // With lower bound 0;
rgsabound[0].cElements=lHigh + 1;
psa=SafeArrayCreate(VT_BSTR, 1, rgsabound);
//Copy the existing data into the new one...
SafeArrayCopyData(pArrMimeMap,psa);
//set the properties of the new mimetype object...
ptrMimeType->put_Extension((_bstr_t)objCMimeType.GetMimeExtension().c_str());
ptrMimeType->put_MimeType((_bstr_t)objCMimeType.GetMimeExtension().c_str());
//assign the mime type object to the variant...it is of type IDispatch...
vntNewMimeType.pdispVal = ptrMimeType;
//put the variant in safe array...
lIndex = lHigh-1;
SafeArrayPutElement(psa,&lHigh,(void*)&vntNewMimeType);
//now return the newly created safe array in the variant...
vntMimeMap.parray=psa;
//save the data..
hr= ptrADs->PutEx(ADS_PROPERTY_UPDATE,L"MimeMap",vntMimeMap);
if(FAILED(hr))
{
strErr = GRANT_BY_DEFAULT_FAILED;
//LOG_ERROR_MESSAGE(m_wstrClassName,m_wstrMethodName,GRANT_BY_DEFAULT_FAILED);
throw hr;
}
//********************************************************
}//end try
CATCH_BLOCK1(m_lError,strErr)
//delete all the pointers...
//TRACE_END(m_wstrClassName,m_wstrMethodName)
return m_lError ;
}
- vc 添加HTTP mime类型
- 添加http mime类型脚本
- HTTP MIME类型
- HTTP MIME类型
- HTTP MIME 类型
- http mime类型
- 添加 MIME 类型
- IIS添加mime类型
- iis添加mime类型
- IIS MiME 添加json类型
- http mime type 类型/子类型
- HTTP 传输类型&MIME类型 整理
- ContentType 输出流的HTTP MIME 类型
- 输出流 HTTP MIME类型列表
- IIS服务器上添加MIME类型
- 在配置文件中添加mime类型
- MIME Types MIME 类型
- MIME Types MIME 类型
- 转载Silverlight AutoCompleteBox 增强key/value 拼音头检索
- 人在上海 想找北京工作 求异地求职经验分享
- 关于OnTimer
- WorkBook的SaveAs方法
- 我想下载啊
- vc 添加HTTP mime类型
- PHP Garbage Collector 引起的Session回话问题
- 我要挣积分下东西啊。。
- eclipse java 源代码修改后运行失效
- 跳转页面等待加载情况的解决
- 模板之小试牛刀---我有点明白为什么这么多人骂c++了(终,算法改变世界)
- 检查n个皇后问题
- OpenGL的2个.Net版本
- KMP串匹配算法