static int nCount=0;
//char pszBuffer;
CFileDialog filediag(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Shapefile(*.shp) |*.shp|",NULL);
CString strPathName,strFileName;
DWORD dwLayerHandle;
ShpfileType shpfileType;
char szPathName[300];
if(filediag.DoModal()==IDOK)
{
strPathName=filediag.GetPathName();
strFileName=filediag.GetFileName();
strcpy(szPathName,strPathName);
//strPathName
if(nCount==0)
{
g_pFirst=new strLayer;
g_pLayerList=g_pFirst;
g_pLayerList->pShapefile=new IShapefilePtr;//调试的时候发现返回的为0
(*g_pLayerList->pShapefile)->Open(szPathName,NULL);

这段代码是从一个工程里面移植过来的,再以前的工程里面都好好的,到这个新的就出问题了!!!!!!!!!
高手指点,谢谢!!!!!!!!!!!!!

解决方案 »

  1.   

    IShapefilePtr CoCreateInstance()能否创建
      

  2.   

    IShapefilePtr你需要通过 CoCreateInstance()创建
    或者是通过其他的接口再创建这个接口
      

  3.   

    我试一试!弱弱的问一下,CoCreateInstance的第一个CLSID 和接口IID怎样传进去!??
    我用oleview能得到
    uuid(C0EAC9EB-1D02-4BD9-8DAB-4BF922C8CD13),
      helpstring("Shapefile Class")
      uuid(5DC72405-C39C-4755-8CFC-9876A89225BC),
      helpstring("IShapefile Interface"),
    怎么做?????