Hello,
I am trying to call c++ dll function calls from C#. The c++ dll function
takes in pointer to unsigned char array. Can anybody help me in what
marshalling parameter value that i have to declare in C# side.
For eg:
in c++ X.dll the function is:
extern "C" __declspec(dlle xport) void Getcharpointer( unsigned char* v)
{
//Just for test purpose, i alter and check on the C# side whether it
persists. This is another thing which i want to do but i cant.
v[0] = 'p';
}
on the c# side declaration:
--------------------------
[DllImport("X.dl l",CharSet=Char Set.Auto)]
static extern Getcharpointer([MarshalAs( UnmanagedType.L PStr )]
System.String IncharPtr)
-----
IF i try this syntax, the change doesnt persist in the value of the first
index of unsigned char pointer array.
Can anybody help me here?.Is this is the right way?.
Thanks.,
Chellam. 1 9676
On Tue, 14 Sep 2004 16:13:05 -0700, cbachellam wrote: Hello, I am trying to call c++ dll function calls from C#. The c++ dll function takes in pointer to unsigned char array. Can anybody help me in what marshalling parameter value that i have to declare in C# side.
For eg: in c++ X.dll the function is: extern "C" __declspec(dlle xport) void Getcharpointer( unsigned char* v) { //Just for test purpose, i alter and check on the C# side whether it persists. This is another thing which i want to do but i cant. v[0] = 'p'; }
on the c# side declaration: -------------------------- [DllImport("X.dl l",CharSet=Char Set.Auto)] static extern Getcharpointer([MarshalAs( UnmanagedType.L PStr )] System.String IncharPtr) -----
IF i try this syntax, the change doesnt persist in the value of the first index of unsigned char pointer array. Can anybody help me here?.Is this is the right way?.
Thanks., Chellam.
using System.Text.Str ingBuilder instead of string...
--
Tom Shelton [MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ivan |
last post by:
Hi All,
I have a problem with marshaling complex structures (containing numbers,
strings, arrays of another structures) to native C function in dll.
I have already posted same question to .compactframework thread, but nobody
helped.
main problem is that I have tried all the workarounds I have found in the
Inet but nothing worked...
I tried passing IntPtr, Byte Arrays, Serialisation, even used OpenNETCF, but
|
by: wallacej |
last post by:
Does anybody know why
unsigned char myImage; works but
unsigned char myImage; does not?
I think its because the second line is a value too big for unsigned
char, is this correct?
If so:
|
by: Roy Hills |
last post by:
When I'm reading from or writing to a network socket, I want to use a
struct to represent the structured data, but must use an unsigned char
buffer for the call to sendto() or recvfrom().
I have two questions:
1. Is it generally safe to "overlay" the structure on the buffer,
e.g.:
unsigned char buffer;
|
by: b83503104 |
last post by:
When are they not consistent?
|
by: Daniel Brown |
last post by:
I am coding a managed C# wrapper for an unmanaged C DLL and I am unable to
marshal a structure that contains an array of structures. When executed, the
following code throws an ArgumentException with a description “Type
ErrorInjectionBuffer can not be marshaled as an unmanaged structure; no
meaningful size or offset can be computed.” I have also included snippets
from the .H file. Any assistance would be greatly appreciated.
...
| |
by: Ivan |
last post by:
Hi All,
I have a problem with marshaling complex structures (containing numbers,
strings, arrays of another structures) to native C function in dll.
I have already posted same question to .compactframework thread, but nobody
helped.
main problem is that I have tried all the workarounds I have found in the
Inet but nothing worked...
I tried passing IntPtr, Byte Arrays, Serialisation, even used OpenNETCF, but
|
by: cdrom205 |
last post by:
static void MDString ( unsigned char *input)
{
MD5_CTX context;
unsigned char digest;
unsigned int len = sizeof(input);//strlen (const char*)
md5.MD5Init (&context);
md5.MD5Update (&context, input, len);
// void MD5Update (MD5_CTX *context, unsigned char *input, unsigned
|
by: ryanlee101 |
last post by:
I am getting a exception error when I complie my code.
The error is:
- imageData 0x00000000 <Bad Ptr>
type unsigned char *
I think it is from when I declare some of my char variables
|
by: Yevgen Muntyan |
last post by:
Hey,
Why is it legal to do
union U {unsigned char u; int a;};
union U u;
u.a = 1;
u.u;
I tried to find it in the standard, but I only found that
|
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: 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 projectplanning, coding, testing, and deploymentwithout 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |