Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Without getting into the specifics, you need to overcome two hurdles: 1) Since you don't have the original .h (header) file, you're guessing as to what it could be, based on the API documentation. Hopefully you'll get it right, but there may be some subtle things in the header file that won't be in the documentation, such as structure packing, calling convention, name mangling, etc. You can start by assuming the defaults for this stuff. Bottom line you have to experiment.</p> <p>2) You are attempting to create P/Invoke calls into a C DLL when you don't have the original header file. You don't know even know if you know how to make these calls from C, much less C#.</p> <p>By doing this straight from C#, you're trying to attack these two issues at the same time. when something doesn't work, you're not sure if it's because you go the P/Invoke syntax wrong, or it's an issue related to your interpretation of what the header file content looks like. I'd try to attack these problems one at a time. First, try to make the DLL calls from a simple C console app. This shouldn't be difficult to create, then hand build a .H file, and very that you can make all the calls.</p> <p>After you're done with that, you now have to get those calls to work from C#.</p> <p>Frankly, I avoid P/Invoke unless I can just reuse one that someone else created (from <a href="http://PInvoke.net" rel="nofollow noreferrer">http://PInvoke.net</a>) for the Windows API. If I were you, and I already new how to make the calls from C, I'd just create a C++/CLI wrapper DLL for it. The advantage is that, you make the calls exactly as you do in the console app -- no P/Invoke necessary. And then expose those calls from the C++/CLI DLL as .NET. Your C# code will call the C++/CLI DLL, which looks just like (and is) a .NET component, with no weird P/Invoke stuff in the C# code.</p> <p>Good luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload