473,659 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in Passing 1d array from VC++ to VB

Hi all,

I have VB applicatoin , which calls a function in VC++ DLL

Arguement of function is a one dimensional string array.

Array will get filled in VC++ dll function.

I have written the programme given below.

But I am unable to get the array elements from VC++.

Programme is given below.

VC++ COM
/*************** *************** ***********/
STDMETHODIMP CTest111CL::myF un(SAFEARRAY **ppOutputArray )
{
AFX_MANAGE_STAT E(AfxGetStaticM oduleState())

HRESULT hresult;

SAFEARRAYBOUND aDim[1] ;

aDim[0].lLbound = 0;
aDim[0].cElements = 3;

BSTR HUGEP *pbstr;

*ppOutputArray = SafeArrayCreate (VT_BSTR , 1, aDim);

hresult=SafeArr ayAccessData(*p pOutputArray,(v oid HUGEP**)&pbstr) ;

pbstr[0] = SysAllocString( OLESTR("SOURCE_ VA"));
pbstr[1] = SysAllocString( OLESTR("ACV"));
pbstr[2] = SysAllocString( OLESTR("10"));

SafeArrayUnacce ssData(*ppOutpu tArray);

return S_OK;
}
/*************** *************** *************** */

VB Application
---------------
''''''''''''''' '''''''''''''
Dim i As Test111CL

Private Sub Command1_Click( )

Dim arr_str(3) As String
Set i = New Test111CL
i.myFun arr_str()
MsgBox arr_str(1)
End Sub

''''''''''''''' '''''''''''

MsgBox arr_str(1) , The message Box shows and empty string.

How can I rectify it. Please help me.

Thanks
George

Feb 9 '07 #1
2 2096
George wrote:
Hi all,

I have VB applicatoin , which calls a function in VC++ DLL
You'd be better off asking on a VC or general windows programming group.

--
Ian Collins.
Feb 9 '07 #2
* George:
>
I have VB applicatoin , which calls a function in VC++ DLL
That's off-topic in clc++m (see the FAQ). Try posting in e.g.
[comp.os.ms-windows.program mer.win32]. Or see the FAQ for other
suggestions.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4195
by: Linux Inquirer | last post by:
Hi Guys, I need to pass a C structure of this form from VB6 <-> VC++ 6 struct BTag { int rowIndex; BSTR* valueList; } B;
11
2059
by: Tatu Portin | last post by:
I have a struct: typedef struct { char **user_comments; int *comment_wds; int comments; char *vendor; } vorbis_comment;
1
3438
by: Kurt Richardson | last post by:
Hi all Sorry to bother you with what is probably a really trivial question for you C++ experts. My programming skill are pretty amateur, but I'm pretty good at VB.NET. However, I'm wanting to realise some of the speed benefits of writing some of my routines in C++ and accessing them from my VB software. I have managed to do this with a few simple routines in
8
10707
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
3
1771
by: Wild Wind | last post by:
Hello, I made a post relating to this issue a while back, but I haven't received any answer, so here I am again. I am writing a mixed C++ dll which uses the following declaration: typedef System::Byte ByteArray __gc;
1
5440
by: Arsalan Ahmad | last post by:
Hi all, I am trying to compile some source files using makefile. While compiling I am getting errors as shown below. Any idea how can I solve this problem. I believe I need to add some preprocessor directives but I dont know which one. Thanks, Arsalan
0
1806
by: parekh | last post by:
Hi All , I am facing a problem wherein my VB project is not recognizing a change in the argument list of a method ( the method itself being declared and defined in another VC++ project and it is now updated to accept one more additional argument ). The problem in detail is as follows: I have a Class (named Student ) in an existing VC++ project. One of its Methods has the following signature and accepts 2 arguments ...
4
11222
by: daroman | last post by:
Hi Guys, i've problem with my small C++ programm. I've just small template class which represetns a array, everything works fine up to combination with std::string. I did tried it with M$ VC++ and with GCC (Cygwin and Linux) and my problem is when i try do this int main(int argc, char **argv) { array<std::stringa(10); a = "Huhuhu"; <--- with gcc i got a crash !
2
2845
by: Phoenix | last post by:
Hi Friends , Could anyone please help me to resolve the following issue : I pass an array of structures to a dll written in VC++ 6.0 whih fills it with data . The following works well for VB 6.0 but when I wrote the same piece of code in VB 2005 the array of structures remained empty even after the API call : I have a structure as follows :
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8535
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8629
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2757
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.