I have a C++/CLI app that uses a logging control in an ATL COM Server. C++
Interop seems to work just fine to pass data from the C++/CLI app to the ATL
Control but I can't seem to figure out how to get a string value back from
the ATL Control. When debugging the code seen below, I see that the VARIANT
pointed to by 'data' is updated but the String 'str' passed from the C++/CLI
app doesn't change. So the String 'str' seems to be passed by value rather
than reference but I can't seem to get anything else to work without throwing
out C++ interop. Any suggestions?
System::Void button2_Click(S ystem::Object^ sender, System::EventAr gs^ e)
{
System::String^ str("temp");
this->axLogCtl1->GetLogText(str );
richTextBox1->Text = str;
}
HRESULT LogCtl::GetLogT ext(VARIANT* data)
{
CComVariant v(m_strData);
/////////////////////////////////////////////////////////////////
// Pass the current log data to the caller.
/////////////////////////////////////////////////////////////////
if (VT_BSTR == data.vt)
v.CopyTo(&(data .bstrVal));
return (S_OK);
}
--
Paul - Consultant: C++ Application Design and Development 3 2677
Oops... Example should be as follows:
HRESULT LogCtl::GetLogT ext(VARIANT* data)
{
CComVariant v(m_strData);
/////////////////////////////////////////////////////////////////
// Pass the current log data to the caller.
/////////////////////////////////////////////////////////////////
if (VT_BSTR == data->vt)
v.CopyTo(&(data->bstrVal));
return (S_OK);
}
--
Consultant: C++ Application Design and Development
"spd3001" wrote:
I have a C++/CLI app that uses a logging control in an ATL COM Server. C++
Interop seems to work just fine to pass data from the C++/CLI app to the ATL
Control but I can't seem to figure out how to get a string value back from
the ATL Control. When debugging the code seen below, I see that the VARIANT
pointed to by 'data' is updated but the String 'str' passed from the C++/CLI
app doesn't change. So the String 'str' seems to be passed by value rather
than reference but I can't seem to get anything else to work without throwing
out C++ interop. Any suggestions?
System::Void button2_Click(S ystem::Object^ sender, System::EventAr gs^ e)
{
System::String^ str("temp");
this->axLogCtl1->GetLogText(str );
richTextBox1->Text = str;
}
HRESULT LogCtl::GetLogT ext(VARIANT* data)
{
CComVariant v(m_strData);
/////////////////////////////////////////////////////////////////
// Pass the current log data to the caller.
/////////////////////////////////////////////////////////////////
if (VT_BSTR == data.vt)
v.CopyTo(&(data .bstrVal));
return (S_OK);
}
--
Paul - Consultant: C++ Application Design and Development
How is the axLogCtl1->GetLogText() method defined in C++/CLI?
If you want the value back, you should define the parameter as an out or ref
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExte nsions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensio ns.Net : Develop all shell extensions,expl orer bars and BHOs
rapidly in .Net
---------
"spd3001" <sp*****@discus sions.microsoft .comwrote in message
news:FA******** *************** ***********@mic rosoft.com...
>I have a C++/CLI app that uses a logging control in an ATL COM Server. C++
Interop seems to work just fine to pass data from the C++/CLI app to the
ATL
Control but I can't seem to figure out how to get a string value back from
the ATL Control. When debugging the code seen below, I see that the
VARIANT
pointed to by 'data' is updated but the String 'str' passed from the
C++/CLI
app doesn't change. So the String 'str' seems to be passed by value
rather
than reference but I can't seem to get anything else to work without
throwing
out C++ interop. Any suggestions?
System::Void button2_Click(S ystem::Object^ sender, System::EventAr gs^ e)
{
System::String^ str("temp");
this->axLogCtl1->GetLogText(str );
richTextBox1->Text = str;
}
HRESULT LogCtl::GetLogT ext(VARIANT* data)
{
CComVariant v(m_strData);
/////////////////////////////////////////////////////////////////
// Pass the current log data to the caller.
/////////////////////////////////////////////////////////////////
if (VT_BSTR == data.vt)
v.CopyTo(&(data .bstrVal));
return (S_OK);
}
--
Paul - Consultant: C++ Application Design and Development
Finally got it to work as follows:
System::Void toolStripButton 1_Click(System: :Object^ sender,
System::EventAr gs^ e)
{
IntPtr ip = Marshal::AllocH Global(0x00007F FF);
void * p = ip.ToPointer();
BYTE * pStr = (BYTE *) p;
this->axLogCtl1->GetLogText(*pS tr);
richTextBox1->Text = Marshal::PtrToS tringAuto(ip);
Marshal::FreeHG lobal(ip);
}
HRESULT LogCtl::GetLogT ext(BYTE * data)
{
_tcscpy_s((TCHA R *) data,
0x00007FFF/sizeof(TCHAR),
(const TCHAR *)m_strData.Get Buffer());
return (S_OK);
}
--
Consultant: C++ Application Design and Development
"G Himangi" wrote:
How is the axLogCtl1->GetLogText() method defined in C++/CLI?
If you want the value back, you should define the parameter as an out or ref
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExte nsions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensio ns.Net : Develop all shell extensions,expl orer bars and BHOs
rapidly in .Net
---------
"spd3001" <sp*****@discus sions.microsoft .comwrote in message
news:FA******** *************** ***********@mic rosoft.com...
I have a C++/CLI app that uses a logging control in an ATL COM Server. C++
Interop seems to work just fine to pass data from the C++/CLI app to the
ATL
Control but I can't seem to figure out how to get a string value back from
the ATL Control. When debugging the code seen below, I see that the
VARIANT
pointed to by 'data' is updated but the String 'str' passed from the
C++/CLI
app doesn't change. So the String 'str' seems to be passed by value
rather
than reference but I can't seem to get anything else to work without
throwing
out C++ interop. Any suggestions?
System::Void button2_Click(S ystem::Object^ sender, System::EventAr gs^ e)
{
System::String^ str("temp");
this->axLogCtl1->GetLogText(str );
richTextBox1->Text = str;
}
HRESULT LogCtl::GetLogT ext(VARIANT* data)
{
CComVariant v(m_strData);
/////////////////////////////////////////////////////////////////
// Pass the current log data to the caller.
/////////////////////////////////////////////////////////////////
if (VT_BSTR == data.vt)
v.CopyTo(&(data .bstrVal));
return (S_OK);
}
--
Paul - Consultant: C++ Application Design and Development
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nadav |
last post by:
Hi,
Introduction
***************
I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system:
API Consumer ( Native C++/C# )
||
*******************************************
* ...
|
by: Razzie |
last post by:
Hey all,
I'm really going through a small hell right now - I've completely lost it :)
I made a project, using two interop libraries from exchange (created them as
in this msdn article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmtps/html/writingmngsinks.asp). I
set my project properties as 'Register as COM interop' to true, I can
install it my project on my developement machine without a flaw. Great.
|
by: glenn |
last post by:
I have a COM Server that I've written based on information from the book
..NET and COM / the complete Interop Guide. I have gotten the project to
compile and I've located the regasm.exe program that I was suppose to run
against my dll in order to generate a TLB file for the purposes of importing
the COM object into other programming lanugages such as Delphi.
However, when I try to import the type library into Delphi which I have done...
|
by: Jeffery Franzen |
last post by:
Anyone know where the documentation is regarding Activex controls in asp web forms?
I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app.
I do the add control to pallete and then add a reference. I get the interop dll added to bin folder.
I did this with the MediaPlayer activex control as a simple case to to try and get it working.
I set the control to autostart via the html parameter tag for...
|
by: Peter Afonin |
last post by:
Hello,
I have a simple client-side form that is checking the domain availability on
the domain registrar's server:
<FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl" method="post">
<input type="hidden" name="thisPage" value="pispCheckDomain">
<input type="hidden" name="username" value="test">
<input type="hidden" name="password" value="test">
domain_name: <input type="text" name="domain_name"><br>
| |
by: Nathan Sokalski |
last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an event is fired by one of the controls contained in the User Control, these variable are reset. Here is my current code (I have a little more to add later, right now I am just concerned about the variables getting reset):
Public Class DatePicker2...
|
by: kagorami |
last post by:
Q: How do you return a LPSTR from unmanaged code?
A: Use a StringBuilder.
What about this:
public struct CSTRUCT {
string return_value;
}
How do you get a LPSTR from unmanaged code when it is in a STRUCT?
|
by: R Reyes |
last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly
to work in my VS2005 project? I'm trying to manipulate MS Word from my Web
Form application and I can't get passed this screen below. Please help,
thanks in advance...
Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify...
|
by: OuTCasT |
last post by:
Hi
I have created an asp.net project that exports items from datagridview to and outlook calendar
This is the code that i have used..
Dim body As String
Dim ends As String
Dim location As String
Dim start As String
Dim subject As String
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |