Get data by SAFEARRAY** from COM(VB Code) in My VC COM Project (Code Part)
来源:互联网 发布:信用卡怎么在淘宝套现 编辑:程序博客网 时间:2024/05/17 09:24
以下是我在一个COM(VC)项目中从 VB 编写的另一个 COM 里通过 SAFEARRAY** 获得数据的代码
USES_CONVERSION;
HRESULT ret = m_iAWChange.CoCreateInstance(__uuidof(Application));
m_iAWChange->Server = m_iAgileServer;
AgileObjectsConstants aocChange = otChange;
SAFEARRAY* sReturnValues;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].cElements = 2;
rgsabound[0].lLbound = 0;
BSTR ObjNumber = ::SysAllocString(L"");
BSTR xSubClass = ::SysAllocString(L"");
long onlyClassID = 0;
long lArg6 = 0;
sReturnValues = SafeArrayCreate(VT_NULL,2,rgsabound);;
VARTYPE vt;
try
{
long lTmp = m_iAWChange->QuickCreate(&aocChange, &sReturnValues, &ObjNumber, &xSubClass, &onlyClassID);
SafeArrayGetVartype(sReturnValues, &vt);
if (vt != VT_BSTR)
return S_FALSE;
long Dims = SafeArrayGetDim(sReturnValues);
long UpperBounds;
long LowerBounds;
char strTemp[100];
/*
for(int i=1; i<=4; i++)
{
for(int j=1; j<=4; j++)
{*/
BSTR tmp;
long indices[] = {2, 1};
SafeArrayGetElement(sReturnValues, indices, (void *)&tmp);
wcstombs(strTemp, tmp, 100);
memset(strTemp, 0, 100);
/*
}
}
*/
}
catch(_com_error &err)
{
std::string strError = "Fail to load the MenuFile, ";
strError += (const char*)err.Description();
return FALSE;
}
return S_OK;
COM 中的 VB 代码原型
'****************************************************************************************************
'Function QuickCreate
'Purpose: Used by the calling app to display the quick create dialog to create an object.
'Parameters: lCreateType - Determines the type of object to be created.
' sReturnValues() - Used to get the newly created object's data. Will be a three columns, 1 based,
' one row array containing the created object's subclass, number and description.
' sObjectNumber - Optional. Used to propose an object number.
' sSubClass - Optional. Used to propose subclass.
' lOnlyClassId - Optional value specifying that only subclasses of the given ClassID should be
' displayed.
'Calls: GetSubClasses() - To get the possible subclasses to fill the combo box control.
' GetClassID() - To get a subclass' ID based on its description.
' CreateObject() - To actually create the object based on the user selected values.
'Returns: 1 if an item was created with all attributes set, 2 if the item was created but not all of the attributes could be set,
' 0 if the user cancelled and -1 if an error occurred and the object couldn't be created.
'****************************************************************************************************
Public Function QuickCreate(lCreateType As AgileObjectsConstants, sReturnValues() As String, Optional sObjectNumber As String, Optional sSubClass As String, Optional lOnlyClassId As Long = 0) As Long
- Get data by SAFEARRAY** from COM(VB Code) in My VC COM Project (Code Part)
- COM from code project
- Getting IErrorInfo part of com error in Managed Code
- COM code
- data transfer between COM, VC, VB (VcToVBtoVC)
- 解决:Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'.错误!
- Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'. Resolved version
- Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app':报错解决
- 记一次错误:Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'.错误!
- Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project
- Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project '
- http://beyondcow.com/code/
- code.google.com无法访问
- 使用Code.google.com
- Git code.google.com
- Calling Managed .NET C# COM Objects from Unmanaged C++ Code
- go get code.google.com/p/go.net/websocket失败
- http://www.newxing.com/Code/VC/index_4.html
- How to access 2 dimensions SAFEARRAY data
- 我的2005高考作文:出人意料和情理之中
- data transfer between COM, VC, VB (VcToVBtoVC)
- 神偷请战
- 且慢下手
- Get data by SAFEARRAY** from COM(VB Code) in My VC COM Project (Code Part)
- ASP VBScript 函数速查表
- Thinking in java(1)
- 管理软件厂商的利润瓶颈
- 微软全球副总裁李开复:学习如何成为企业家
- 关于static变量,成员变量和局部变量
- 未来成功企业家三要素
- ADO 中的并发编码
- 游泳,我喜欢