09-12-2005 05:04 AM
I am trying to write a small application which writes to the datasocket server at regular intervalls. In OnInitDialog() I’ve added the following code:
m_dataSocketConnectionString="dstp://localhost/level_in_percent";
int status = m_myDataSocket.Status;
if (status == CNiDataSocket::Unconnected)
{
m_myDataSocket.Connect(m_dataSocketConnectionString, CNiDataSocket::WriteAutoUpdate);
}
m_pTimer= new CNiTimer(0.5, false);
m_pTimer->InstallEventHandler(*this, TimerEvent);
m_pTimer->Start();
Now the problem is that the line:
int status= m_myDataSocket.Status;
in the member function TimerEvent raises an NiOleException. When using GetErrorMessage() I get ”CoInitialize has not been called”. What am I doing wrong?
Adam
09-12-2005 08:47 AM
09-12-2005 09:35 AM
Thank you for a swift reply! The solution worked fine.
Adam
07-03-2009 06:20 AM
Hi,CNiOleException raised when I want to call a function which is in a dll.
The code in the function is;
try{
CNiDataSocket socket;
socket.Init(model,threadAccess);
socket.URL = "psp:\\\\localhost\\Untitled Library 5\\voltaj";
socket.SetAccessMode(socket.ReadAutoUpdate);
socket.Connect();
CNiDataSocketData data = socket.GetData();
double val = data.GetValue();
return val;
}
catch(const char aMessage[])
{
cout << endl
<< aMessage
<< endl;
}
and in the first line of the code, CNiOleException raised.
Do you have any idea about the problem?
Thanks
Ozan