C++调用VB.NET编的dll中的类,出现编译错误,望各位大侠指点!
下面是给出的VB编写的标准程序,我需要转为C++Private Sub FormMain_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
End Sub
Private Sub FormMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
' Clean Up
On Error Resume Next
m_objPQView23.Disconnect()
m_objPQView23 = Nothing
End Sub
Private Sub FormMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Create a new PQView23 class
m_objPQView23 = New PQView.PQView23
With m_objPQView23
.Database = "F:\王鑫\pqview\电科院PQView讲座资料\二次开发培训资料\Databases\PQViewDemo2008.mdb"
.Provider = "Jet"
.Connect()
If Not .Connected Then
MsgBox(.ErrDesc, MsgBoxStyle.Critical, "Connection Error")
End If
End With
' Initialize the data range
Me.DateTimePickerStart.Value = #2/10/2003#
Me.DateTimePickerFinish.Value = #2/11/2003#
' Initialize the list of demonstration options
With
.Items.Add(demoGetConnectionAliasList)
.Items.Add(demoGetInfo)
.Items.Add(demoGetSites)
.Items.Add(demoGetSitePropertyValuesPivot)
.Items.Add(demoGetSteadyStateSamples)
.Items.Add(demoGetSteadyStateSamplesPivot)
.Items.Add(demoGetSteadyStateSamplesStat)
End With
End Sub
以上是编的程序,从动态库PQView.dll中调用类PQView23,动态库PQView.dll是用vb编写的。本人也是初学者,不是计算机出身,试着写了下面的程序,可惜编译不过。希望各位指点下!!
int main()
{
//typedef HRESULT (__stdcall * pPQView)(REFCLSID,REFIID,void**);
//pPQView PQView= NULL;
//HINSTANCE hdllInst = LoadLibrary("C:\Windows\System32\PQView.dll");
//PQView=(pPQView)GetProcAddress(hdllInst,"DllGetClassObject");
//if (PQView != 0)
//{
// IClassFactory* pcf = NULL;
// HRESULT hr=(PQView)(_PQView23,IID_IClassFactory,(void**)&pcf);
// if (SUCCEEDED(hr) && (pcf != NULL))
// {
// _PQView23* pPQView23 = NULL;
// hr = pcf->CreateInstance(NULL, __uuidof(PQView23), (void**)&_PQView23);
// if (SUCCEEDED(hr) )
// {
// //pPQView23->Database = "pqview-sample.mdb";
// //pPQView23->Provider = "Jet";
// pPQView23->Connect();
// if(pPQView23->Connected)
// {
// printf("数据库连接成功");
// }
// else
// {
// printf("数据库连接失败");
// }
// }
// pcf->Release();
// }
//}
//FreeLibrary(hdllInst);
vb的程序是标准程序,我要转为c++ 不知道怎么回事 编译不过,dll是用vb编写的,多谢各位指教了!!!!!! 程序目的就是调用动态库PQView.dll中的类PQView23