467,144 Members | 1,156 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,144 developers. It's quick & easy.

Create Instance Failed!

Hi, all
Could any boday tell me why I failed to create instance here in the
following code ?

Codes sample
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------

Thanks in advance!

Joseph
Jul 20 '06 #1
  • viewed: 5485
Share:
3 Replies
"Joseph Lu" <jo******@yahoo.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
Could any boday tell me why I failed to create instance here in the
following code ?
...
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------
Um, what is the value of hr?

Regards,
Will
Jul 20 '06 #2
the value of hr is : 0x800401f0 , my code is very simple, I used VC to
create a dialog based application and the create a new button on the dialog,
then I added a button click event to this app ,and I have listed the code as
my previous mail detailed .
"William DePalo [MVP VC++]" <wi***********@mvps.org写入消息
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Joseph Lu" <jo******@yahoo.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
> Could any boday tell me why I failed to create instance here in the
following code ?
...
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------

Um, what is the value of hr?

Regards,
Will

Jul 20 '06 #3
Well , I got it, I find I need to call AfxOleInit() before create instance!

"Joseph Lu" <jo******@yahoo.com写入消息
news:ux**************@TK2MSFTNGP03.phx.gbl...
the value of hr is : 0x800401f0 , my code is very simple, I used VC to
create a dialog based application and the create a new button on the
dialog, then I added a button click event to this app ,and I have listed
the code as my previous mail detailed .
"William DePalo [MVP VC++]" <wi***********@mvps.org写入消息
news:%2****************@TK2MSFTNGP05.phx.gbl...
>"Joseph Lu" <jo******@yahoo.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
>> Could any boday tell me why I failed to create instance here in the
following code ?
...
--------------------------------------------------------------------
void CInsertDataTestDlg::OnBnClickedButton1()
{
_ConnectionPtr pMyConnect=NULL;
HRESULT hr=pMyConnect.CreateInstance(__uuidof(Connection)) ;
if(FAILED(hr))return ;
AfxMessageBox(_T("Successfull connected!"), MB_OK)
}
--------------------------------------------------------------------

Um, what is the value of hr?

Regards,
Will


Jul 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Shashikant Khandelwak | last post: by
2 posts views Thread by R. Clausen | last post: by
9 posts views Thread by jab | last post: by
20 posts views Thread by Hemant Shah | last post: by
4 posts views Thread by etuncer@gmail.com | last post: by
reply views Thread by Terry Reedy | last post: by
6 posts views Thread by Mr. X. | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.