-
December 24th, 2019, 06:06 AM
#1
Passing structure form c# to Visual Studio C
Dear All,
I am trying to pass a C# structure to a C dll program and it does not work.
In the C program, the expected structure is like :
Code:
typedef struct _Identification
{
char szName[50];
char szSurname[50];
}
I try to define the c# structure like :
Code:
public unsafe struct _Identification
{
public fixed char szName[50];
public fixed char szSurname[50];
}
But it does not work.
How to define that expected structure in c# so as to pass it correctly ?
Thank you for help
James W.
Last edited by 2kaud; December 24th, 2019 at 06:08 AM.
-
December 24th, 2019, 06:56 PM
#2
Re: Passing structure form c# to Visual Studio C
I'm trying to understand what you are trying to do.
From a C# program are you trying to pass data to a dll (written in c)?
-
December 25th, 2019, 02:22 PM
#3
Re: Passing structure form c# to Visual Studio C
Dear Arjay,
My solution is implemented in two part :
- the first part in c# where SQL instrcutions and IHM are managed to find out a group of customers based on some criteria;
- the second part in dll C where calculations are made; This second part is supposed to receive data from the c# program.
Yes, I am trying to pass data to a dll (written in c).
Regards
-
December 25th, 2019, 02:50 PM
#4
Re: Passing structure form c# to Visual Studio C
Read up on using pinvoke in google (it's how C# calls exported functions in a c dll).
Also look at pinvoke.net for sample declarations.
-
December 25th, 2019, 02:55 PM
#5
Re: Passing structure form c# to Visual Studio C
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|