Hello ,
I meet some data convertion problem, the sample code as following,
namespace Configure
{
using namespace System ;
typedef struct _SW{
char szVersion[64] ;
} SW,*PSW ;
public __gc class Config{
public :
SW m_sw ;
public :
Config(char *szVersion)
{
Config __pin *This = this ;
strcpy(this->m_sw.szVersion ,szVersion) ;
} ;
}
Assume the calling code as following,
Config *pCfg1 = new Config("1.0.0.1 ") ;
char szVer[64]="Applicatio n ver." ;
szVer=strcat(sz Ver,pCfg1->m_sw.szVersion ) ;
-->Here still get an error : can't conver char[64] to const char *
My question is how to convert managed char array to unmanaged char*?
Does anyone can help me to resolved this problem? Thank you very much.
Tsung-Yu 1 2148
Although you get a pinned pointer to "this" in the constructor, you use the
unpinned version in your call to strcpy. Try to use the pinned version
"This" instead!
"joye" <jo**@askey.com .tw> schrieb im Newsbeitrag
news:OU******** ******@TK2MSFTN GP10.phx.gbl... Hello ,
I meet some data convertion problem, the sample code as following,
namespace Configure { using namespace System ;
typedef struct _SW{ char szVersion[64] ; } SW,*PSW ;
public __gc class Config{ public : SW m_sw ; public : Config(char *szVersion) { Config __pin *This = this ; strcpy(this->m_sw.szVersion ,szVersion) ; } ; }
Assume the calling code as following,
Config *pCfg1 = new Config("1.0.0.1 ") ; char szVer[64]="Applicatio n ver." ; szVer=strcat(sz Ver,pCfg1->m_sw.szVersion ) ;
-->Here still get an error : can't conver char[64] to const char *
My question is how to convert managed char array to unmanaged char*? Does anyone can help me to resolved this problem? Thank you very much.
Tsung-Yu
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Weston Fryatt |
last post by:
(Sorry for spamming multiple groups, But I need a solution to this problem)
I think this should be a simple question on Memory Allocation in a managed DLL and passing a memory pointer over to an unmanaged DLL.
I have a "Unmanaged" Client DLL that I'm creating a Managed "wrapper" to be used in VB.Net and/or C#..
In the my Client DLL (unmanaged), There are several functions where I need to allocate a "client side" memory buffer to...
|
by: Ekim |
last post by:
hello,
I'm allocating a byte-Array in C# with byte byteArray = new byte;
Now I want to pass this byte-Array to a managed C++-function by reference,
so that I'm able to change the content of the byteArray and afterwards see
the changes in C#.
(if you wanna know more details: the goal is to write the content of an
existing char-array in c++ precisely into the passed byteArray, so that
after the function has proceded the content of the...
|
by: Omid Hodjati |
last post by:
Hi All,
I implemented an encryption algorithm using C#, native C++
and managed C++. Then I measured the CPU time used for
executing this algorithm in all implementation. The
managed version of C++ was the worst ! It is 20 times
slower that the native version and 6 times slower that the
C# versio !!
Because i wanted to use automatic memory management
offered by .Net framework, i used the managaed classes
available. e.g. i have used...
|
by: joye |
last post by:
Hello,
How to convert an unmanaged string with char array type to a managed string
with char array type?
Thanks.
Regards,
Tsung-Yu
|
by: joye |
last post by:
Hello ,
I meet some data convertion problem, the sample code as following,
namespace Configure
{
using namespace System ;
typedef struct _SW{
char szVersion ;
| |
by: Serge BRIC |
last post by:
My application, written in .NET VB, tries to get a communication port handle
from a TAPI object with this code:
Dim vFileHandle As Byte() = appel.GetIDAsVariant("comm/datamodem")
The vFileHandle is supposed to be a file handle (an IntPtr, I suppose). How
can I convert this Byte() in this IntPtr ?
|
by: Aston Martin |
last post by:
Hi All,
********************** My Situation **********************
I am working on project that involves passing a structure to unmanaged
code from .Net world (well using C#). Perhaps an example will prove
useful.
structure MyStruct
{
// this is a complicated struct declaration in the sense
|
by: DavidT |
last post by:
Hello,
at first, exuse if the following question is simple to solve, but i normaly coding with C# and now have to use C++/CLI for one project.
My Problem is that i have to use a native c++ sdk to read pictures from ip cameras. I get the native c++ decoder worked so far and now try to send callbacks from unmanaged to managed code, to signal wenn a picture is fully received.
To get a first view on that area i implemented a little test...
|
by: DavidT |
last post by:
Hello,
at first, exuse if the following question is simple to solve, but i
normaly coding with C# and now have to use C++/CLI for one project.
My Problem is that i have to use a native c++ sdk to read pictures
from ip cameras. I get the native c++ decoder worked so far and now
try to send callbacks from unmanaged to managed code, to signal wenn a
picture is fully received.
|
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: 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,...
|
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: 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...
|
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
| |