//此函式是將txt檔案中的點集轉化生成shp檔案
IFeatureLayerPtr CPolygonDlg::CreateShpFromPoint(CString strShp)
{
int index = strShp.ReverseFind('\\');//找到最后一個\的位置
CString strfolder = strShp.Left(index+1);
int len = strShp.GetLength();
CString strFileTitle = strShp.Right(len-index-1);
IWorkspaceFactoryPtr pWSF = NULL;
HRESULT hr = pWSF.CreateInstance(__uuidof(esriCore::ShapefileWorkspaceFactory)); /////////////// 此步出錯/////////////
if (FAILED(hr))
AfxMessageBox(_T("file"));
IFeatureWorkspacePtr pFWS = (IFeatureWorkspacePtr)(pWSF->OpenFromFile(_bstr_t(strfolder),0));
除錯資訊如下:
HRESULT CreateInstance(const CLSID& rclsid, IUnknown* pOuter = NULL, DWORD dwClsContext = CLSCTX_ALL) throw()
{
HRESULT hr;
_Release();
if (dwClsContext & (CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)) {
IUnknown* pIUnknown;
///////////////運行到下面的CoCreateInstance函式出錯,出錯
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast<void**>(&pIUnknown));
if (SUCCEEDED(hr)) {
hr = OleRun(pIUnknown);
if (SUCCEEDED(hr)) {
hr = pIUnknown->QueryInterface(GetIID(), reinterpret_cast<void**>(&m_pInterface));
}
pIUnknown->Release();
}
}
錯誤顯示: hr: 0x80040111 ClassFactory 無法供應請求的類
pIUnknown: 0x00000000 ------正常情況這個地方是有值的,但是不知道 為什么沒有
引數pIUnknown顯示: __vfptr = CXX0030: 錯誤: 無法計算運算式的值
有大神幫一把么?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/54899.html
上一篇:手殘升級了vs2017,沒了win32控制臺專案了,windows控制臺專案直接亂碼
下一篇:剛開始學習c++求指點
