dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Passing structure form c# to Visual Studio C

  1. #1
    Join Date
    Dec 2019
    Posts
    5

    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.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,208

    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)?

  3. #3
    Join Date
    Dec 2019
    Posts
    5

    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

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,208

    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.

  5. #5
    Join Date
    Dec 2019
    Posts
    5

    Re: Passing structure form c# to Visual Studio C

    I wil try it.
    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)