dllimport

“Unable to find an entry point named [function] in dll” (c++ to c# type conversion)

你。 提交于 2019-11-28 19:23:03
I have a dll which comes from a third party, which was written in C++. Here is some information that comes from the dll documentation: //start documentation RECO_DATA{ wchar_t Surname[200]; wchar_t Firstname[200]; } Description: Data structure for receiving the function result. All function result will be stored as Unicode (UTF-8). Method: bool recoCHN_P_Name(char *imgPath,RECO_DATA *o_data); Input: char * imgPath the full path of the image location for this function to recognize RECO_DATA * o_data data object for receiving the function result. Function return: True if Success, otherwise false

Call C# dll function from C++/CLI

こ雲淡風輕ζ 提交于 2019-11-28 12:02:00
I have a C# dll. The code is below: public class Calculate { public static int GetResult(int arg1, int arg2) { return arg1 + arg2; } public static string GetResult(string arg1, string arg2) { return arg1 + " " + arg2; } public static float GetResult(float arg1, float arg2) { return arg1 + arg2; } public Calculate() { } } Now, I am planning to call this dll from C++ on this way. [DllImport("CalculationC.dll",EntryPoint="Calculate", CallingConvention=CallingConvention::ThisCall)] extern void Calculate(); [DllImport("CalculationC.dll",EntryPoint="GetResult", CallingConvention=CallingConvention:

Run Fortran DLL with Visual Studio

蓝咒 提交于 2019-11-28 11:49:32
I develop a website with Visual Studio 2010. I want to run a Fortran DLL. I used Intel Visual Fortran to create a .dll and to test how to use it. My code is: SUBROUTINE SIMPSON (N,H,I) !DEC$ ATTRIBUTES DLLEXPORT, DECORATE, ALIAS : "SIMPSON" :: SIMPSON !DEC$ ATTRIBUTES REFERENCE::N !DEC$ ATTRIBUTES REFERENCE::H !DEC$ ATTRIBUTES REFERENCE::I INTEGER N,H,I I=N+H RETURN END which practically takes two integers, adds them and return the result. Now I have the .dll I don't know how to run it with Visual Studio. Can anyone who knows please give me steps to follow? ja72 I do this all the time. What I

unable to read another application's caption

我怕爱的太早我们不能终老 提交于 2019-11-28 11:34:52
问题 Jumping of how i will find windows handle in my main program... in C# I run notepad.exe then type something in it,then find the main window handle using SPY++ (0x111111) ,and [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount); . . . GetWindowText((IntPtr)(0x111111), str, 1024); this code works fine and return me the caption of the main window. : : but when i do the same to

C++ : inline functions with dllimport/dllexport?

℡╲_俬逩灬. 提交于 2019-11-28 10:31:58
I create a DLL (say CORE.DLL) ,I have classes/functions declared as follows: #ifdef RINZOCORE_SHARED #define RINZO_LIB __declspec(dllexport) #else #define RINZO_LIB __declspec(dllimport) #endif I have defined many inline functions with "dllexport" macro , class RINZO_LIB CVector { public: CVector();//!< default constructor .. real& x();//!< accessor for the x component (can be used as l-value too) real& y();//!< accessor for the y component (can be used as l-value too) real& z();//!< accessor for the z component (can be used as l-value too) CVector& operator=(const CVector& other);//!< the

Pass multi - dimensional array from managed code to unmanaged code

╄→гoц情女王★ 提交于 2019-11-28 10:11:00
I would like to do the following: Create three dimesinal array in c# code like this: var myArray = new short[x,y,z]; UnanagedFunction(myArray); Pass it to unmanaged code (c++) like this: void UnmanagedFunction(short*** myArray) { short first = myArray[0][0][0]; } UPDATED When I try the following code I have runtime error: Attempted to read or write to protected memory. Thank you!!! IntPtr Array3DToIntPtr(short[, ,] Val) { IntPtr ret = Marshal.AllocHGlobal((Val.GetLength(0) + Val.GetLength(1) + Val.GetLength(2)) * sizeof(short)); int offset = 0; for (int i = 0; i < Val.GetLength(0); i++) { for

Why doesn't .NET find the OpenSSL.NET dll?

梦想与她 提交于 2019-11-28 10:10:01
EDIT (the whole question, it was too unclear) I want to use OpenSSL.NET The OpenSSL.NET install instructions page: INSTALL Make sure you have libeay32.dll and ssleay32.dll in the current working directory of your application or in your PATH. DONE In your .NET project, add a reference to the ManagedOpenSsl.dll assembly. DONE I have put libeay32.dll and ssleay32.dll in both my bin/Debug and bin/Release directories. I have also put them in system32 . Here is my FULL code: using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { try { OpenSSL.Crypto.RSA rsa =

DllImport Returning null terminated string AccessViolationException

痞子三分冷 提交于 2019-11-28 05:02:59
问题 I am trying to interface with a Dll that implements several functions, one of which takes a null terminated string and an int, and returns a null terminated string. I have attempted to interface with the method like this: [DllImport(dll_loc)] [return : MarshalAs(UnmanagedType.LPStr)] public static extern StringBuilder GetErrorMessage([MarshalAs(UnmanagedType.LPStr)] StringBuilder message, int error_code); I then attempt to call the method like this: StringBuilder message = new StringBuilder

ver.2 PyGreSQL ERROR: from _pg import * ImportError: DLL load failed: The specified module could not be found

血红的双手。 提交于 2019-11-28 04:34:07
问题 I have the same problem that was discussed here, but I haven't credit to comment an answer so I start new question. I have in PATH way to libpq.dll (C:\PostgreSql\lib) but it doesn't solve this problem. Using Python 2.7.9 32-bit, PostgreSQL 8.4, Win 8 Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> import pg File "C:\Python27\lib\site-packages\pg.py", line 21, in <module> from _pg import * ImportError: DLL load failed: The specified module could not be found. 回答1: I

DllImport and char*

孤街醉人 提交于 2019-11-28 04:06:40
问题 I have a method I want to import from a DLL and it has a signature of: BOOL GetDriveLetter(OUT char* DriveLetter) I've tried [DllImport("mydll.dll")] public static extern bool GetDriveLetter(byte[] DriveLetter); and [DllImport("mydll.dll")] public static extern bool GetDriveLetter(StringBuilder DriveLetter); but neither returned anything in the DriveLetter variable. 回答1: It appears the function GetDriveLetter is expecting a char* which points to sufficient memory to contain the drive letter.