Enable to call C dll in VB.net Code

2019-08-22 13:54发布

问题:

I am running into a problem which I am using C Dll into my VB.net code. I have .H file which shows implementation of this DLL in C language. This .H file contains many structures and unions that contain variable of some structures type. There is a main structure which contains the pointers to these structures and unions and finally address of main structure is passed into the dll function.

I am enable to figure out how to create structures and unions with marshalling in vb.net and how to pass address of a structure which contains addresses of othere structures and unions.

Please me to solve this issue. Any help would be appreciated.

Thanks, YOgi

回答1:

There is a free tool CLRInsideOut that will convert your C structure definitions to VB.NET PInvoke code. Read more on MSDN here. Disclaimer: JaredPar should really get any rep points for this answer since he wrote some of the tool.



回答2:

Since you don't provide much detail about your problem I can only help you by directing you to the documentation. You can read more about platform invoke and how to marshal structures and unions on MSDN