Home > Net >  C # use C library files, how to receive a structure secondary pointer
C # use C library files, how to receive a structure secondary pointer

Time:11-26

Everybody is good, now want to ask you a c #, thank you for your reply
It is like that, I call a dynamic library of c + +, prototype is like this:
Struct ImageBinHeader
{
DWORD magic;
DWORD version;
WORD hchsum;
WORD dchsum;
DWORD dsize.
DWORD load_addr;
DWORD entry_point;
DWORD img_len;
DWORD img_attr;
DWORD next_section_addr;
BYTE name [4];
BYTE priv [24].
};
LINKAGE ImageBinHeader * * PMC_FwParserGetFileInfoByHandle (int handle);

That I how to write in c #, whether to write like this?
Public struct ImageBinHeader
{
Public uint magic;
Public uint version;
Public ushort hchsum;
Public ushort dchsum;
Public uint dsize.
Public uint load_addr;
Public uint entry_point;
Public uint img_len;
Public uint img_attr;
Public uint next_section_addr;
Public byte [] name;
Public byte [] priv;
};
[DllImport (@ "phoenixMC. DLL," EntryPoint="PMC_FwParserGetFileInfoByHandle CharSet=CharSet. The Unicode, CallingConvention=CallingConvention. Cdecl)]
Public static extern IntPtr PMC_FwParserGetFileInfoByHandle (int handler);


Also, the calling code what to write? I surf the Internet to search some information in the past two days, but did not say to c + + secondary pointer in c # to how to write, how to invoke specific use, which tall person can give a piece of code? Thank you very much!

I don't so call OK!!!!!!
ImageBinHeader imageInfo=new ImageBinHeader ();
ImageBinHeader imageInfo=new ImageBinHeader ();
Public void parse_FWInfo (int FWHandler) {
IntPtr PTR=PMC_FwParserGetFileInfoByHandle (FWHandler);
ImageInfo=(ImageBinHeader) Marshal. PtrToStructure (tmp1, typeof (ImageBinHeader));
}

CodePudding user response:

https://blog.csdn.net/u011430225/article/details/78675163

With this

CodePudding user response:

https://github.com/jaredpar/pinvoke-interop-assistant

It seems to have a new version of the
  •  Tags:  
  • C#
  • Related