Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 768629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:12:44+00:00 2026-05-14T18:12:44+00:00

this is my first post here! I’m trying to make a windows forms program

  • 0

this is my first post here!

I’m trying to make a windows forms program using C# which will use a precompiled C library. It will access a smart card and provide output from it.
For the library, I have a .dll, .lib and .h and no source. In the .h file there are several structs defined. Most interesting functions of the .dll expect pointers to allocated structs as arguments. I’ve been calling functions inside the .dll like this: For example function

EID_API int WINAPI EidStartup(int nApiVersion);

would be called like this

[DllImport("CelikApi.dll")]//the name of the .dll
public static extern int EidStartup(int nApiVersion);

Now my problem is that I can’t find equivalent of C’s pointers which point to dynamically allocated structures in memory in C#, so I don’t know what to pass as argument to functions which take C pointers.

I don’t have much experience in C#, but to me its use looked as the easiest way of making the program I need. I tried with C++, but Visual Studio 2010 doesn’t have IntelliSense for C++/CLR. If you can point me to something better, feel free to do so.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:12:44+00:00Added an answer on May 14, 2026 at 6:12 pm

    You can do something like

        [DllImport("Operations.dll")]
        public static extern void Operation(
            [MarshalAs(UnmanagedType.LPArray)]ushort[] inData, 
            int inSize1, int inSize2,
            [MarshalAs(UnmanagedType.LPArray)]int[] outCoords,
            ref int outCoordsSize);
    

    That code will take a dynamically allocated array of unsigned shorts (ushort in C#), as well as multiple size parameters (inSize1 and inSize2), and place results in the outCoords array of size outCoordsSize.

    Your C code cannot allocate memory and expect C# to play nice with it; C# should allocate all memory that your C code plays with. In the above case, you could put the size of the outCoords array in outCoordsSize, and then replace the value of outCoordsSize with the amount of memory you actually used (which cannot exceed the amount of memory you originally allocated without an exception).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 422k
  • Answers 422k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Check the AVAudioPlayer class here http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/AudioandVideoTechnologies.html#//apple_ref/doc/uid/TP40007072-CH19-SW1 Should tell you what… May 15, 2026 at 11:16 am
  • Editorial Team
    Editorial Team added an answer Turns out the JRE System Library and the Websphere Application… May 15, 2026 at 11:16 am
  • Editorial Team
    Editorial Team added an answer Here's the js function: function validateString(regexPattern, testString) { var regexObj… May 15, 2026 at 11:16 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.