dllimport

How to get char** using C#? [duplicate]

耗尽温柔 提交于 2019-11-29 17:51:57
问题 This question already has an answer here: Marshal an array of strings from C# to C code using p/invoke 3 answers C# call C++ DLL passing pointer-to-pointer argument 3 answers I need to pass an argument to an unsafe DllImported function in the form of: [DllImport("third_party.dll")] private static extern unsafe int start(int argc, char** argv); I'm assuming it's an array of strings. However when I try to do the following, I get 'Cannot convert from string[] to char**' error. How do I go about

PYTHON - Ctypes : OSError: exception: access violation writing 0xFFFFFFFFFA1C001B

白昼怎懂夜的黑 提交于 2019-11-29 17:24:56
Here is a code for writing values to memory using memory mapping. When I try to run the code, I get the error "File "MMF.py", line 26, in memcpy(pBuf, szMsg, len(szMsg)) OSError: exception: access violation writing 0xFFFFFFFFFA1C001B" import msvcrt, mmap import ctypes from ctypes import * FILE_MAP_ALL_ACCESS = 0x04 INVALID_HANDLE_VALUE = 0xFFFFFFFF SHMEMSIZE = 256 PAGE_READWRITE = 0x04 szName = ctypes.c_wchar_p("MyFileMappingObject") szMsg = "Message from Python(ctypes) process" hMapObject = windll.kernel32.CreateFileMappingA(INVALID_HANDLE_VALUE,None, PAGE_READWRITE, 0, SHMEMSIZE, szName)

unable to read another application's caption

泪湿孤枕 提交于 2019-11-29 17:15:34
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 find caption of the child of notepad.exe it just set str to nothing. the spy++ told me that the child's

Getting distorted images after sending them from C# to OpenCV in C++?

风流意气都作罢 提交于 2019-11-29 14:48:58
I created a C DLL out of my C++ class which uses OpenCV for image manipulations and want to use this DLL in my C# application. Currently, this is how I have implemented it: #ifdef CDLL2_EXPORTS #define CDLL2_API __declspec(dllexport) #else #define CDLL2_API __declspec(dllimport) #endif #include "../classification.h" extern "C" { CDLL2_API void Classify_image(unsigned char* img_pointer, unsigned int height, unsigned int width, char* out_result, int* length_of_out_result, int top_n_results = 2); //... } C# related code: DLL Import section: //Dll import [DllImport(@"CDll2.dll", CallingConvention

Using 32-bit dll on 64-bit system shows 0x8007000B Error

感情迁移 提交于 2019-11-29 14:05:20
I have to use a third party DLL in my application. The DLL is a 32-bit and the system I am using is 64-bit OS. I have Imported the 32-bit DLL in my DotNet application (framework-4.5) as below [DllImport("Sample.dll", EntryPoint = "Add", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern int Add(int iA, int iB); In IIS 7.5 - I have set "Enable 32-bit Application" as "True". And also tried setting the Compiler Manager as - X86, x64 and Any CPU. But all the attempt results in same Error as An attempt was made to load a program with an incorrect format.

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

怎甘沉沦 提交于 2019-11-29 11:11:05
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. I was also facing the same issue on Win 8 . First time I had installed PostgreSQL in "C:\Program Files" and

PInvoke char* in C DLL handled as String in C#. Issue with null characters

时间秒杀一切 提交于 2019-11-29 09:39:24
The function in C DLL looks like this: int my_Funct(char* input, char* output); I must call this from C# app. I do this in the following way: ...DllImport stuff... public static extern int my_Funct(string input, string output); The input string is perfectly transmitted to the DLL (I have visible proof of that). The output that the function fills out although is wrong. I have hexa data in it, like: 3F-D9-00-01 But unfortunately everything that is after the two zeros is cut, and only the first two bytes come to my C# app. It happens, because (I guess) it treats as null character and takes it as

How to set up a C++ function so that it can be used by p/invoke?

*爱你&永不变心* 提交于 2019-11-29 09:24:59
问题 Hopefully this is a brainlessly easy question, but it shows my lack of expertise with C++. I'm a C# programmer, and I've done extensive work with P/Invoke in the past with other people's C++/C dlls. However, this time I've decided to write a wrapper C++ dll (unmanaged) myself, and am then calling my wrapper dll from C#. The problem I am immediately running into is that I am unable to define a C++ function that can be found by p/invoke. I don't know what the syntax for this is, but here's what

P/Invoke dynamic DLL search path

守給你的承諾、 提交于 2019-11-29 09:23:18
I have an existing app which P/Invokes to a DLL residing in the same directory as the app itself. Now (due to the fact that Canon produces one of the crappiest API's around) I need to support two versions of this API and determine at run-time which one I should use (old or new). Since the DLLs have the same name (the first one loads other DLLs with same names so just renaming the first one won't help me) I must keep them in different directories. Hence my question: what options do I have to control what directory the DLL given in a DllImport declaration uses? I guess I can start out by trying

Parameterising DllImport for use in a C# application

我怕爱的太早我们不能终老 提交于 2019-11-29 07:55:59
问题 We have a supplier who provides a library for access to their hardware. Unfortunately, if you have multiple devices, you need to import their library multiple times, with different dll names. As a consequence, we have a metric ton of duplicated code, and I'm worried that it will soon become be a maintenance nightmare. What we have at the moment is somthing like: namespace MyNamespace { public static class Device01 { public const string DLL_NAME = @"Device01.dll"; [DllImport(DLL_NAME,