dllimport

Calling Unmanaged C++ from C#

荒凉一梦 提交于 2019-12-23 18:34:12
问题 I'm running VS2012 on Win7 with .NET 4.0. I've tried the following: Create C++ DLL project Checked\Unchecked the export symbols box I've made sure my platform targets are the same. In my case, win32 I've added the necessary extern "C" and __declspec(dllexport) where needed. I've successfully compiled my DLL and have tried to reference it in a C# project. Unfortunately, I get an error telling my it can't be added and that I need to make sure it's a valid assembly or COM object. I've given up

Import names in ELF binary

大憨熊 提交于 2019-12-23 10:07:11
问题 Where does the ELF format stores the names of imported functions? Is it always possible to enumerate all import names, like for PE executables? For example, if a binary is using printf is it possible to tell it does, just by static analysis of the binary itself? 回答1: In ELF they're called undefined symbols. You can view the list of undefined symbols by: nm -D <file>|grep -w U objdump -T <file>|grep "\*UND\*" ELF files don't specify which symbols come from which libraries; it just adds a list

CoInitialize() has not been called exceptions in C++

偶尔善良 提交于 2019-12-23 07:26:37
问题 - My problem I got CoInitialize has not been called exption. - My project structure Here is my porblem. I have a COM dll, MCLWrapper.dll developped with C#; I have a nother native C++ dll, ThorDetectorSwitch.dll that calls MCLWrapper.dll; And finally, I have a console application TDSTest.exe that calls ThorDetectorSwitch.dll. Basically, something like this: TDSTest.exe (C++ console) -> ThorDetectorSwitch.dll (C++ native) -> MCLWrapper.dll (C#) Code in TDSTest.exe that loads the

Exporting C++ dll to c# [closed]

限于喜欢 提交于 2019-12-23 06:40:25
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . 'using System; 'using System.Collections.Generic; 'using System.Drawing; 'using System.Windows.Forms; 'using Emgu.CV; 'using Emgu.CV.Structure; 'using Emgu.CV.CvEnum; 'using System.IO; 'using System.Diagnostics;

Method's type signature is not PInvoke compatible

若如初见. 提交于 2019-12-23 03:17:16
问题 I am trying to use a function from a c dll, in a c# application, I am facing this error each time i try to run the application and call the function in question. At first i thought maybe this is because of the wrong signature i am using, but i tried to make it as simple as possible yet no luck.! To cut a long story short: This is my actual source code for c dll : #include <stdio.h> #include <string.h> extern "C" { struct teststruct { char acharacter; int anumber; char* astring; char anarray

C# DllImport and Marshaling char**

ε祈祈猫儿з 提交于 2019-12-23 02:59:15
问题 I'm working in c# and I need to use this function from a c++ dll: extern "C" char IMPEXP __stdcall service_GetParameter ( const char* parameter, const int value_lenght, char** value ); I have used it in c++ code as follow: char *val = new char[256]; service_GetParameter("firmware_version", 255, &val); AnsiString FirmwareVersion = val; delete[] val; How can I import this function and use it in c#? Thanks in advance 回答1: If this function allocates memory and makes the caller responsible for

How do I call this Delphi method in C# using Dllimport?

送分小仙女□ 提交于 2019-12-23 02:25:09
问题 New Programmer in need of Help! The Delphi code that is compiled into the DLL function SetCurrentSerial(Size : Integer; Msg : Pointer) : Integer stdcall; var TempByte : PByte; TempStr : string; i: Integer; begin Result := 0; TempByte := Msg; TempStr := ''; for i := 0 to Size - 1 do begin TempStr := TempStr + ' '; end; for i := 0 to Size - 1 do begin TempStr[i+1] := Chr(TempByte^); Inc(TempByte); end; if not DLLClass.SelectDeviceSerial(TempStr) then begin Result := -1; end; end; The C# Code /

Mouse move in game window by outer C# code

泄露秘密 提交于 2019-12-22 17:05:50
问题 I am playing a game, every time I need to move mouse and click into the game's screen to earn game point, so I am trying to write code by c# to click and move mouse in game's screen automatically .. I got some help, so mouse click problems solved, but I am unable to move mouse in game's screen.. Can you please advice me what should I do ?? Should I use "SetWindowsHookEx" or other methods to move mouse in game window ?? Please advice me what should I do.. "Click" code below which I got, it's

Access violation exception when use method Marshal.PtrToStructure in a loop

落爺英雄遲暮 提交于 2019-12-22 12:40:42
问题 In my program (C#), i used method Marshal.PtrToStructure to convert object add a memory address to structure in a loop. At the first element, this work normal. But at the second element, the access violation exception occurs. The access violation exception only occurs on win 7 (64 bits), it does not occur on win xp (32 bits). I don't know cause and solution for it. Please help me. Note: I use .NET Framework 3.5. Code as bellow: [StructLayout(LayoutKind.Sequential)] public struct gpc_vertex {

Calling C from C#

不羁的心 提交于 2019-12-22 12:38:09
问题 I am from electric engineer background, therefore my knownledge is small about C#,DLL,etc.... I want to use c function into a C#. I know there is a couple post about that but I didn't find one that is enough simple. Currently, I got C function call windows API to read/write on the USB port. First to create a .dll do I need a header file? Because I got the following function decleration function into a header. The examples that I saw on stack overflow and Internet only use a simple .c file,