dllimport

Problem with importing DLL into Inno-Setup

若如初见. 提交于 2019-12-13 02:30:08
问题 I am importing an C++ DLL in an innosetup install script. The DLL code is as follows: void __stdcall SetFbParam(char *dbFileName,char *dbTableName,char *dbParamName,char *dbParamValue){ //of no use here and doesn't change anything} In the Innosetup, I import it using procedure FBset(dbFileName,dbTableName,dbParamName,dbParamValue: String;); external 'SetFbParam@files:MyDll.dll stdcall setuponly'; However, I always get a runtime error during launch of the installer, saying that it cannot

How do I export and link to a dll using Qt Creator on Windows?

試著忘記壹切 提交于 2019-12-13 02:26:35
问题 I have got a few Qt projects building on my Mac and I am currently trying to get the same code to build on Windows. In among these projects there is one dll (call it LibraryA) that exports a class (call it ClassA) that is linked to by a second dll (call it LibraryB). I have the following code that defines the dll export code to be used based on the compiler being used. #ifdef _MSC_VER #if defined(LIBRARY_A) #define LIBRARY_A_EXPORT __declspec(dllexport) #else #define LIBRARY_A_EXPORT _

How to include dll as relative path?

匆匆过客 提交于 2019-12-13 02:00:06
问题 I have a dll in my project which I am referring through absolute path(C:\test\something\abc.dll) to load in my project. How do load it relatively or is there is better way to include it in visual studio project? 回答1: You can specify dll name without path and place the dll in the same directory where the executable loading it resides, or in the current directory (the one from which you launch the program). 回答2: MSDN:: Before the system searches for a DLL, it checks the following: If a DLL with

C# Error Finding Method in DLLImport

半城伤御伤魂 提交于 2019-12-12 23:36:54
问题 I have a C++ assembly that I am importing using DLLImport. I am attempting to call its method: namespace Testing { class Test{ int Run(char* filePath, bool bEntry, double duration){//code} }; } by [DllImport(dllName, CharSet = CharSet.Auto)] public static extern int Run(string filePath, bool bEntry, double duration) ); When I call its method, I get the error message: Unable to find an entry point named Run in dll 回答1: The "Run" looks to be a non-static class method. Although, it's possible to

Where to place an unmanaged DLL for use importing into a C# program?

我是研究僧i 提交于 2019-12-12 23:12:35
问题 This must be a really stupid question, but I'm still very green when it comes to C#. Anyway, I've got a DLL and I'm importing it with a line like this: [DllImport(@"MyCoolDll")] I've lifted this straight from the demo app provided by the vendor, but it keep complaining that it can't find the DLL. The actual error (from Visual Studio 2010) is like this: Unable to load DLL 'MyCoolDll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) I've tried placing the compiled

Attempted to read or write protected memory with dllimport in c#

做~自己de王妃 提交于 2019-12-12 16:50:54
问题 I have a problem with my project: In dll c++: extern "C" __declspec(dllexport) int results(char* imgInput, void* tree) { struct kd_node* nodeTree = new(tree)kd_node ; // new kd_tree with data from memory address ... ... int ret = atoi(retValueStr.c_str()); return ret; } extern "C" __declspec(dllexport) void* buildKDTree(char* folder) { struct kd_node* kd_root; .... feature *LFData = listFeat.data(); kd_root = kdtree_build(LFData,listFeat.size()); void* address_kdtree = (void*)&kd_root; // get

Passing array data between C# and a DLL (both directions)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 13:48:32
问题 I have some C code that compiles to a DLL. From C#, I need to pass an array of ints to it, and I need to get an array of ints out of it. Here's what I have so far. From C#, the only function that works is bar(). It returns 22 and writes to a file as expected. The others write to their files properly but throw an exception when control is given back to C#. It reads, "A call to PInvoke function 'irhax!irhax.App::foo' has unbalanced the stack. This is likely because the managed PInvoke signature

how to call a C++ dll from C# windows application project

最后都变了- 提交于 2019-12-12 13:14:17
问题 I have created a dll in C++ using a Class Library project in Visual Studio. I need to call a method in the dll from a C# application. I got to know there are 2 approches. One is to add the dll project reference to C# project or use DllExport to export method. However when I tried in both ways it always gives the following error when the dll method is called in runtime. An unhandled exception of type 'System.BadImageFormatException' occurred in TestClient.exe Additional information: An attempt

C++ Struct in C#

时光怂恿深爱的人放手 提交于 2019-12-12 12:31:06
问题 I'm using a DLL written in C++ in my C# project by using DllImport and one of the functions I'm using looks like this: [DllImport("dds.dll", CharSet = CharSet.Auto)] private static extern int Par( ddTableResults2 tableResult, ref parResults ParResult, int vul ); The parResults struct is defined in C++ like this: struct parResults { /* index = 0 is NS view and index = 1 is EW view. By 'view' is here meant which side that starts the bidding. */ char parScore[2][16]; char parContractsString[2]

Using GetOpenFileName instead of OpenFileDialog

别来无恙 提交于 2019-12-12 12:16:58
问题 I can't use OpenFileDialog in my application. As an alternative I use GetOpenFileName() method: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace Reader { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public class OpenFileName { public int lstructSize; public IntPtr hwndOwner; public IntPtr hInstance; public string lpstrFilter = null; public string lpstrCustomFilter = null; public int