COM组件把excel的xls转向csv格式

COM组件把excel的xls转为csv格式
HRESULT ConverXLSToCSV(const char *pSrcFileName, const char *pDesFileName)
{
//单线程方式创建COM对象
::CoInitialize(0);
if(1)

//初始化EXCEL对象
CComDispatchDriver execlAppDsp;
HRESULT hr = CoCreateInstance(L"Excel.Application", 0, CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER);
//获取工作页,打开XLS文件
CComVariant vWorkbooks;
hr = execlAppDsp.GetPropertyByName(L"Workbooks", &vWorkbooks);
CComDispatchDriver booksDsp(vWorkbooks.pdispVal);
CComVariant vSrcFileName(pSrcFileName);
hr = booksDsp.Invoke1(L"Open", &vSrcFileName);
//关闭警告对话框
CComVariant vDisplay(L"FALSE");
hr = execlAppDsp.PutPropertyByName(L"DisplayAlerts", &vDisplay);
//打开活动页,另存为CSV文件
CComVariant vActBook;
hr = execlAppDsp.GetPropertyByName(L"ActiveWorkbook", &vActBook);
CComDispatchDriver activeBookDsp(vActBook.pdispVal);
CComVariant vDesFileName(pDesFileName);
CComVariant vFileType("6");
hr = activeBookDsp.Invoke2(L"SaveAs", &vDesFileName, &vFileType);
//关闭EXCEL
execlAppDsp.Invoke0(L"Quit");
}
//释放
::CoUninitialize();
return S_OK;
}

其中HRESULT hr = CoCreateInstance(L"Excel.Application", 0, CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER);这条语句少了几个参数,请问怎么加呀?
------解决方案--------------------
查MSDN呀

STDAPI CoCreateInstance(

  REFCLSID rclsid,

  LPUNKNOWN pUnkOuter,

  DWORD dwClsContext,

  REFIID riid,

  LPVOID * ppv

);
 

Parameters
rclsid 


[in] CLSID associated with the data and code that will be used to create the object. 
pUnkOuter 


[in] If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown). 
dwClsContext 


[in] Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX. 
riid 


[in] Reference to the identifier of the interface to be used to communicate with the object. 
ppv 


[out] Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL. 
Return Values
S_OK 


An instance of the specified object class was successfully created. 
REGDB_E_CLASSNOTREG 


A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt. 
CLASS_E_NOAGGREGATION 


This class cannot be created as part of an aggregate. 
E_NOINTERFACE 


The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface. 
------解决方案--------------------
Remarks
The CoCreateInstance helper function provides a convenient shortcut by connecting to the class object associated with the specified CLSID, creating an uninitialized instance, and releasing the class object. As such, it encapsulates the following functionality:

  Copy Code 
CoGetClassObject(rclsid, dwClsContext, NULL, IID_IClassFactory, &pCF); 

hresult = pCF->CreateInstance(pUnkOuter, riid, ppvObj) 

pCF->Release(); 
 

It is convenient to use CoCreateInstance when you need to create only a single instance of an object on the local machine. If you are creating an instance on remote machine, call CoCreateInstanceEx. When you are creating multiple instances, it is more efficient to obtain a pointer to the class object's IClassFactory interface and use its methods as needed. In the latter case, you should use the CoGetClassObject function.