Dear All,
I am trying to call the data type unsigned char * included in the C DLL and whole structure from C Sharp.
My draft code is below -
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
-
public struct Converted
-
{
-
public int width;
-
public int height;
-
public IntPtr Buf; // which is unsigned char* in C and is it correct ?
-
//[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
-
-
};
-
-
Converted c = new Converted();
-
[DllImport("Test.dll", CharSet = CharSet.Auto, EntryPoint="Loading")]
-
public static extern Converted Loading(ref IntPtr buf, int size, int type); // shoul I use ref?
-
-
i.data is syste.array
-
c.Buf = Loading(ref i.data, i.size, type);
-
-
I encountered
1. to pass unsigned char * from C to C#
2. return structure of Converted from C to C#
3. System.array of C# to IntPtr of C# or unsigned char *
I hope some one will advise me to get it well for my dll and looking forward to hearign from you soon.
Thanks in advance
2 2418
Dear All,
I am trying to call the data type unsigned char * included in the C DLL and whole structure from C Sharp.
My draft code is below -
// dll.cpp
-
// Image Display and BufferMemory
-
typedef
-
struct ConvertedImage
-
{
-
int height;
-
int size;
-
unsigned char *greyBMPBuf;
-
}ConvertedImage;
-
-
MATCH_IMPORTS ConvertedImage Convert2BMPGrey(unsigned char *bufFromDevice, int size, int image_type);
-
-
// main.cs
-
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
-
public struct ConvertedImage
-
{
-
public int width;
-
public int height;
-
public int size; // size = imagesize is imagewidth * imgaeheight
-
[MarshalAs(UnmanagedType.LPArray)]
-
public byte[] greyBMPBuf;
-
};
-
-
ConvertedImage cImage;
-
-
[DllImport("Match.dll", CharSet = CharSet.Auto, EntryPoint = "Convert2BMPGrey")]
-
public static extern ConvertedImage Convert2BMPGrey([MarshalAs(UnmanagedType.LPArray)]byte[] bufImage, int size, int image_type);
-
I encountered
1. to pass unsigned char * from C to C#
2. return structure of Converted from C to C#
3. System.array of C# to IntPtr of C# or unsigned char *
4. the error message"Method's type signature is not PInvoke compatible"
Please advise me for my dll and C# InteropServices and looking forward to hearing from you good news.
Thanks in advance
Please don't double-post your questions. It divides attempts to help you in an organized and cohesive manner. Your threads have been merged
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jr |
last post by:
I am working in VC++ so this may be microsoft specific though I don't think
so. Excuse me if it is.
Assuming it isn't, can someone generally explain the purpose of having
both - is it purely a...
|
by: mdaetwyler |
last post by:
Hi all
I am trying to call a DB/2 v8.2 stored procedure from Perl DBI and am
getting an error message telling me, that the routine could not be
found in the library path.
SQL0444N Routine...
|
by: Kenric Li |
last post by:
Hello,
May I know how I can call a calss from a dll implemented by C#, from Visual
C++.net? There is no header file that comes with it. But a documentation
with the list of the class methods...
|
by: Amjad |
last post by:
Hi,
I want to make a project that calls and executes a function (VB code) made
in a seperate file in the Application Folder. I know I can create the
function in my project and call it internally,...
|
by: Daniel Lidström |
last post by:
I'm using a library called fyba. This library reads and writes files in a
format called sosi. fyba uses the following code to determine if the
calling process has own methods to handle errors,...
|
by: Usenet User |
last post by:
I need to be able to call the same API function from VB, which will
reside in different DLLs. While all of the functions have the same
signature and name, DLL file names are not known at compile...
|
by: yhebib |
last post by:
Hello All,
I've been browsing and reading all articles I could find on technet
,msdn and other knowledgeable sources to understand the issue I'm
dealing with.
However, I did not find so far how...
|
by: Frederick Gotham |
last post by:
I gather that, rather than the C++ Standard defining the functionality of
the Standard Library features which it has in common with C, it makes
reference to a C Standard which defines their...
|
by: =?Utf-8?B?VmljdG9yIExhaQ==?= |
last post by:
Hi,
I wrote an simple application using VS2005 C#. I am trying to call some
functions in my other dll file. This dll is written in EVC for running on
Windows CE 5.0.
This dll file has the...
|
by: Even |
last post by:
Hi all,
As far as I know, relative address will be assigned by program at link
time.Right? Ok, here we go.
So if we use a static library, it will give the program an relative
address(i mean...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |