473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

VC++ returns value to VB (Dll)


Return a CString to VB and use it in VB...

I badly need to send text string from VC++(Take note that the type of
my variable is CString !), I'm so disappointed, I tried like 4-5
approches, nothing works !
Please help me before I put that computer into garbage, it's been 2
weeks without having found.
Here is my VC++ function.
I'm able to call it, but the best I got is the first character only...
Anyway..
Have a look.
I cannot change the type from CString to something else, I have to use
CString (Supplied Api...)
VC++
///////////////////////////////////////////////////////////////////////
Should *CString* be the returned type ???????

CString _stdcall SearchLast(int chn)
{
(strTmp2 declared as CString outside)
strTmp2="Nothing";
.......some other code here........
::DxSearchStart( m_hServer, &SearchInfo );
AfxMessageBox(strTmp2);
return strTmp2;

}

VB CODE is below...

////////////////////////////////////////////////////////////////////////

Private Declare Function SearchLast Lib "PelcoDLL.dll" (ByVal Channel
As Integer) As String

Private Sub Command2_Click()
Dim i As String
i = SearchLast(0)
MsgBox i
End Sub

--
floydus
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 17 '05 #1
1 944
>I badly need to send text string from VC++(Take note that the type of
my variable is CString !)


Here's an example of returning a string to VB. Note it doesn't use
CString - VB cannot use a CString.
VB DEFINITIONS:

Declare Function fnReturnString Lib "VBDLLTest.dll" (ByVal x As
String) As String

And the CPP:

#define VBDLLTEST_API __declspec(dllexport)

extern "C"
{
//an example of returning a string from a C DLL routine
VBDLLTEST_API BSTR __stdcall fnReturnString( LPCSTR s1 )
{
BSTR bstr;
bstr = SysAllocStringByteLen( "Hello there dear world",
sizeof("Hello there dear world")-1 );

return bstr;
}

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #2

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

Similar topics

3
by: robert | last post by:
Hi All, I have a problem. I have written a COM DLL in VB6 to do some stuff. I need to call this DLL from a VC++ program for which I have the code. I have managed to get as far as creating the...
8
by: Paul | last post by:
Hi all may I know how to use C# DLL inside my VC++ Project ? Thanks in advance.
0
by: Jim Owen | last post by:
Hi, I have a COM object that I'm trying to use from within a VC++ dll. I'm pretty sure that the COM object was written in VB although we didn't write it. I registered the dll and have been able...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
17
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and...
0
by: sujk2k | last post by:
Hello, my problem is related to marshalling of C data type 'BSTR from the .NET code steps: 1. I have a c# program which calls one function from a VC++ dll file as follows: ...
0
by: D Kon | last post by:
Hi, I have built a VC++.NET dll function in which you pass an array of double data and 2 additional input arguments and it returns a pointer of the data address and 2 additional scallar values. ...
0
by: krishnasamy | last post by:
Hello, I am writing a DLL for Capturing the Image from Camera Device using Camera SDK DLL. All the calls made to functions in Camera SDK DLL are working properly as I am able to get a return...
6
by: Mohamed Fysal | last post by:
Hi, I have a major problem. I am using a VB exe which is having a structure declared and it looks like below Public Type SCANNEDIBUTTNO IButtonUserNumber As String * 32
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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...

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.