// SFB_test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <stdio.h> #import "e:\My Projects\vb\sfb\sfb_Types.dll" no_namespace // atlbase.h required for OLE2A conversion macros #include <atlbase.h> int main(int argc, char* argv[]) { try { CoInitialize(NULL); Boxes b; b.ItemName = SysAllocString(L"This is name of item"); b.GroupTotal = 156; b.x = 3.1415927; _SFB_StruPtr ptr; ptr.CreateInstance(__uuidof(SFB_Stru)); ptr->MyFunction(&b); USES_CONVERSION; Boxes FromVB = ptr->BoxesFunc(); printf("ItemName: %s\n\r", OLE2A(FromVB.ItemName)); printf("x: %f y: %f\n\r", FromVB.x, FromVB.y); } catch(_com_error &e) { BSTR bstrDesc = e.Description(); } CoUninitialize(); return 0; }VB code
Public Type Boxes ItemName As String GroupTotal As Integer Down As Integer Across As Integer x As Double y As Double Arc As String Total As Integer End Type Public Function MyFunction(b As Boxes) Dim msg As String msg = "Item: " & b.ItemName & vbCrLf msg = msg & " Group total: " & b.GroupTotal & vbCrLf msg = msg & " x: " & b.x MsgBox msg End Function Public Function BoxesFunc() As Boxes BoxesFunc.ItemName = "ItemName" BoxesFunc.x = 0.123456789 BoxesFunc.y = 9.87654321 End Function>Alexander, Thanks for giving me a chance to more clearly explain my adversity.