I allways have an error code "800401F0" with a program code, sts = spIPPSession.CreateInstance(clsid);
Can anyone give me an advice to avoid or fix this error?
How should I correct the program source?
Please see the program source as below.
#include "stdafx.h"
//#include "stdio.h"
#import "C:/Program Files/ProjectPoint API Toolkit/ProjectPointClient.dll" no_namespace
//#import "c:\users\hondato\desktop\hondato\mhi nagasaki\bzs_2010\Debug\ProjectPointClient.dll" no_namespace
int bazlink(void);
//-------------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
bazlink();
return 0;
}
//--------------------------------------------------------------------------------------
int bazlink(void)
{
CLSID clsid;
_bstr_t bstrSiteName = "https://webdav.buzzsaw.com/testbuz"; //
_bstr_t bstrUsername = "User1"; //
_bstr_t bstrPassword = "Password1"; //
_bstr_t resultString = "";
HRESULT hr = CLSIDFromProgID(OLESTR("ProjectPointClient.PPScripting.1"), &clsid);
IPPSessionPtr spIPPSession;
spIPPSession = NULL;
long sts;
char buf[10];
sts = spIPPSession.CreateInstance(clsid);
sprintf(buf, "%X", sts);
resultString = buf;
//_bstr_t s = n.ToString("X2");
spIPPSession->LogIn(bstrUsername, bstrPassword, bstrSiteName);
spIPPSession->LogOut ();
return 1;
I just found that I used "ProjectPoint.PPScripting.1" to get clsid, but used it for PPSession CreateInstance.
I also added CoInitialize and CoCreateInstance as below, then the program runs well!!
HRESULT hr = CoInitialize(NULL);
printf("CoInitialize %X\n", hr);
hr = CLSIDFromProgID(OLESTR("ProjectPointClient.PPSession.1"), &clsid);
printf("CLSIDFromProgID %X\n", hr);
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, __uuidof(IUnknown), reinterpret_cast<void**>(&spIPPSession));
printf("CoCreateInstance %X\n", hr);
hr = spIPPSession.CreateInstance(clsid);
printf("CreateInstance %X\n", hr);
hr = spIPPSession->LogIn(bstrUsername, bstrPassword, bstrSiteName);
printf("CreateInstance %X\n", hr);
hr = spIPPSession->LogOut();
printf("CreateInstance %X\n", hr);