用VB写了个ACTIVE.dll(名字是XTDSLIMPORTDATE.dll)
VB中写了下面的代码
ShowForm.class代码:
Private mvartest As Integer
Public Property Let test(ByVal vData As Integer)
mvartest = vData
End Property
Public Property Get test() As Integer
test = mvartest
End PropertyPublic Sub ShowLMForm()
Frm_AddDate.Show 1
End SubFrm_AddDate.form代码
Private mShowForm As New ShowForm
Private Sub CmdToCount_Click()mShowForm.test = tTPartPicNO.Text
msgbox mShowForm.testExit Sub
handlerr:
Debug.Print Err.Description
End SubVC代码:
#import "C:\e-tech\Xtpdm35\pdm\XTDSLIMPORTDATE.dll" no_namespace _ShowFormPtr showForm;
HRESULT showFormhr = showForm.CreateInstance(__uuidof(ShowForm));
showForm->ShowLMForm();
//运行到上面都没有错误.vb中的ShowLMForm方法可以执行。
现在的问题是我如何才能实现vb中的Public Property Get test() As Integer这个方法
用showForm->Gettest();获取编译可以通过但用quickwitch查看会有下面提示
CXX0063:ERROR:overloaded operator->not supported
解决方案 »
- _ConnectionPtr接口返回一个记录集或一个空指针的含义
- 奇怪的问题,关于new CArray的,有空的进来看看
- 加分贴 《500分: 谁能解决者立刻给分,本贴不算,up 有分》
- 真是郁闷阿! 怎么数据没法添加到数据库中?
- 如何刷新系统托盘时间?
- 怎么用OLE操作EXCEL
- 请教如何将在CListCtrl中排序后的项目数据写回原来的链表,使链表中的顺序与CListCtrl中的保持一致。
- 关于Debug和Release(实在搞不定了,请高手指教)
- 搜集一些vc编程资料
- 如何能够截获任何一标准控件获得焦点时的绘制状态???
- 析构函数为什么会被调用两次?
- 求助!上哪能找到工业控制、自动化 相关的技术资料?
int a = showForm->Gettest();
如果这样对,就不管它了呀。
VB6.0
Public Function MyVBFunction(x As Integer) As Integer
MsgBox x
End Function
Public Function MyVBFunction2(s As String) As String
MyVBFunction2 = s & "、返却値は文字列です。"
End Function
Public Function MyVBFunction3(x As Integer) As String()
Dim s(0 To 10) As String
s(0) = "12345"
s(1) = "67890"
s(2) = "ABCDE"
MyVBFunction3 = s
End Function//////////////////////////////////////////////////////////
VC++6.0
#include <stdio.h>
#include <afx.h>#include <iostream>
#include <stdlib.h>
#include <string>#include "atlbase.h"
#include "comutil.h"#import "c:\project1.dll" no_namespace void main()
{
BSTR bstrDesc; try
{
CoInitialize(NULL);
short st = 2;
short st1;
_bstr_t st2;
//_bstr_t st3[10];
SAFEARRAY *st3; _Class1Ptr ptr; ptr.CreateInstance(__uuidof(Class1)); //1.整数返却値
st1 = ptr->MyVBFunction(&st); //2.文字列返却値
st2 = ptr->MyVBFunction2(&st);
CString s;
s.Format(_T("%s"), (LPCTSTR)st2);
printf(s);
printf("\n"); //3.文字列配列の返却値
st3 = ptr->MyVBFunction3(&st); long lIndex;
BSTR szBSTRName; for(lIndex=0;lIndex<3;lIndex++)
{
SafeArrayGetElement(st3, &lIndex, &szBSTRName);
::MessageBoxW( NULL, szBSTRName, L"てすと", MB_OK ); char charVal[10] = "";
WideCharToMultiByte(CP_ACP,0,szBSTRName,-1,charVal,10,NULL,NULL); printf(charVal);
printf("\n");
} }
catch(_com_error &e)
{
bstrDesc = e.Description(); } CoUninitialize();
}