dllimport


C# - Method's type signature is not PInvoke compatible

岁酱吖の 提交于 2020-01-17 15:41:12
问题 I am trying to use the VC++ (2003) dll in C# (2010) When am calling the method of dll from c# am getting this error "Method's type signature is not PInvoke compatible" I am returning the structure from VC++ Code: struct SLFData { public: char ByLat[10]; char ByLong[10]; }; And I am marshalling in C# Code: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SLFData { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public char[] ByLat; [MarshalAs(UnmanagedType

C# DllImport calling un-managed C++ function callback

江枫思渺然 提交于 2020-01-16 09:02:12
问题 Hi I have a C# WinForm app, I am able to call functions from the libnetclient.dll via DllImport like below: [DllImport("libnetclient.dll", CharSet = CharSet.Auto)] public static extern int NETCLIENT_Initialize(int bPriorRGB16 = 0); I am then able to use the functions as normal such as below: int ini = NETCLIENT_Initialize(); memoBox.AppendText("NETCLIENT_Initialize = " + ini.ToString()+Environment.NewLine);//append to box This callback occurs once the login function has completed. My problem

Tutorial needed on invoking unmanaged DLL from C#.NET

痴心易碎 提交于 2020-01-15 09:15:34
问题 I have a DLL from a vendor that I Need to invoke from C#. I know that C# data classes are not directly compatible with C++ data types. So, given that I have a function that receives data and returns a "string". (like this) string answer = CreateCode2(int, string1, uint32, string2, uint16); What must I do to make the input parameters compatible, and then make the result string compatible? Please - I have never done this: Don't give answers like "Use P/Invoke" or "Use Marshal" I need a tutorial

Debugging DLLImport in C#

◇◆丶佛笑我妖孽 提交于 2020-01-15 09:01:00
问题 I have been attempting to get the MySQL Embedded Library working in my C# application for the past 12 hours or so, and have been stuck for quite some time. I am getting the following error when I call mysql_server_init() ... Unhandled Exception: System.AcessViolationException: Attempted to read or write protected memory. The C++ method takes an int and two char** as parameters, but I was told a null terminated string[] array would suffice in C#. As this is the first method that you're

Use a dll from a c++ program. (borland c++ builder and in general)

风流意气都作罢 提交于 2020-01-15 05:26:10
问题 I'm trying to use a dll, namely libcurl, with my program, but, it's not linking. Libcurl comes with .h files that I can include (takes care of dllimport), but then I guess I must specify which dll to actually use when linking somehow... How do I do that? I'm compiling with Borland C++ builder, but I really want to know how these things work in general... EDIT: This is the code (straight c/p from curl homepage) bool FTPGetFile::ConnectToFTP(string ftpServer){ CURL *curl; CURLcode res; curl =

Calling C++ function using DllImport

冷暖自知 提交于 2020-01-15 03:32:05
问题 This one is basic, how do I call the function SubscribeNewsFeed in the following from a C# DllImport? class LogAppender : public L_Append { public: LogAppender() : outfile("TestLog.txt", std::ios::trunc | std::ios::out) , feedSubscribed(false) { outfile.setf(0, std::ios::floatfield); outfile.precision(4); } void SubscribeNewsFeed() { someOtherCalls(); } }; I'm unable to figure out how to include the class name when using the DllImport in my C# program here: class Program { [DllImport(

Obtain a filename from a file handle?

我怕爱的太早我们不能终老 提交于 2020-01-14 10:24:47
问题 I have the ntdll.dll's NtCreateFile() function hooked to allow/deny the access of certain files. Unlike kernel32.dll's CreateFile() which easily gives you the full path to the file in question, ntdll.dll's NtCreateFile() function only gives you the handle to the file. I need to obtain the full path of the file from a file handle, to consequently allow/deny access. I've searched around and there doesn't seem to be a working C# solution. This solution is in C++, and documented from Microsoft. I

Obtain a filename from a file handle?

给你一囗甜甜゛ 提交于 2020-01-14 10:23:26
问题 I have the ntdll.dll's NtCreateFile() function hooked to allow/deny the access of certain files. Unlike kernel32.dll's CreateFile() which easily gives you the full path to the file in question, ntdll.dll's NtCreateFile() function only gives you the handle to the file. I need to obtain the full path of the file from a file handle, to consequently allow/deny access. I've searched around and there doesn't seem to be a working C# solution. This solution is in C++, and documented from Microsoft. I

How do I import MySql Connector into Unity Project?

无人久伴 提交于 2020-01-14 03:28:28
问题 I've tried placing the basic dll's into unity's assets folder - Result: "blah blah will cause Unity to Crash Error." I've tried Manually adding references - Result: Unity refreshes its references anytime the editor refreshes, so worthless. I've tried Installing using NuGet - Result: Closest to success as it handles all the dependencies and whatnot but I get: Assets/Scripts/Developing/TalkToDB.cs(3,7): error CS0246: The type or namespace name `MySql' could not be found. Are you missing an

DllImport vs LoadLibrary, What is the best way?

爱⌒轻易说出口 提交于 2020-01-11 09:41:08
问题 i'm usually using Win32 API in c#.NET. But not declare all in one application. Sometimes usually using user32, sometimes gdi32 ... I think when i declare all api function, those use lot of memory. What is the best way using API in .NET ? 回答1: Most of the Win32 API is available through managed abstractions. Otherwise, declare the ones you need using DllImport . LoadLibrary should really only be used where you have provided alternate functionality, that is, your application can work even

工具导航Map