dllimport

How to include a .h or .dll file in CANoe/CAPL

倾然丶 夕夏残阳落幕 提交于 2019-12-07 07:07:05
问题 I want integrate a header .h or .dll file in CAPL (concretly Visa32.dll, visa.h or sicl.h) to control a multimeter 34461A. How can I include the .h files or .dll file in CANoe? I created an ECU module called multimeter. Thanks, 回答1: Including external DLLs in CAPL is possible, but you will need to create a wrapper for all the functions you're going to use. Take a look at \CANoe\Demo_AddOn\Capldll directorty which features such a wrapper. It's a MSVC project exporting a few simple functions to

How to call from a C# applicaiton a C++ function taking a pointer to void?

痴心易碎 提交于 2019-12-07 06:42:58
问题 I have a dynamic library ( .dll ) written in C++ exporting a function I'd like to use in my C# applicaiton: int SendText(void* pControl, char* sText); How can I, given it takes a pointer to void? 回答1: for void* you can just use IntPtr , strings will work with the MarshalAs attribute: [DllImport("MyDll.dll", CharSet = CharSet.Ansi)] public static extern int SendText(IntPtr pControl, [MarshalAs(UnmanagedType.LPStr)] string sText); 来源: https://stackoverflow.com/questions/10630419/how-to-call

How to compile a C DLL for 64 bit with Visual Studio 2010?

家住魔仙堡 提交于 2019-12-07 05:04:37
问题 I have a DLL written in C in source code. This is the code for the General Polygon Clipper (in case you are interested). I'm using it in a C# project via the C# wrapper provided on the homepage. This comes with a precompiled DLL. Since switching to a 64bit Development machine with Visual Studio 2010 and Windows 7 64 bit, the application won't run anymore. This is the error I get: An attempt was made to load a program with an incorrect format. This is because of DLLImport ing the 32bit gpc.dll

Which DLL is [DllImport] loading?

谁都会走 提交于 2019-12-07 04:27:44
问题 I'm using the [DllImport] attribute to import a native DLL into my application but the DLL it's loading isn't in the local bin folder. It's being loaded from elsewhere on the system, but I can't work out where. It works on my dev machine but not on a clean one. I've enabled Fusion logging and that only shows me managed assemblies. I've dumped the process using Sysinternals Process Explorer and that's telling me it's in C:\Windows\System32 but I can't see the file there in Windows Explorer. It

How would you declare DLL import signature?

北慕城南 提交于 2019-12-07 03:35:39
问题 this is a follow-up post of Using pHash from .NET How would you declare following C++ declaration in .NET? int ph_dct_imagehash(const char* file,ulong64 &hash); So far i have [DllImport(@"pHash.dll")] public static extern int ph_dct_imagehash(string file, ref ulong hash); But I am now getting following error for ulong hash1 = 0, hash2 = 0; string firstImage = @"C:\Users\dance2die\Pictures\2011-01-23\177.JPG"; string secondImage = @"C:\Users\dance2die\Pictures\2011-01-23\176.JPG"; ph_dct

Using Delphi DLL in C#

ぃ、小莉子 提交于 2019-12-07 03:30:56
问题 I have a third party "mystery dll" written with Delphi(unknown version), working example in delphi (past 2009), dire need to use said dll in my C# code, and almost no relevant knowledge on how to do it. Here is Delpi example in using this dll: type TD_Query = function(host: WideString; port : Word;pud,query : WideString):WideString; stdcall; procedure TForm11.Button6Click(Sender: TObject); var Handle : LongWord; D_Query : TD_Query; sss : WideString; begin Handle := LoadLibrary('kobrasdk.dll')

C# DllImport and Marshaling char**

主宰稳场 提交于 2019-12-06 22:34:26
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 If this function allocates memory and makes the caller responsible for freeing it, I'm afraid you'll have to manage this manually: Declare the parameter as a ref IntPtr and use the

Calling C from C#

纵饮孤独 提交于 2019-12-06 13:42:58
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, Can I get rid of the header files? __declspec(dllexport) LMUSB_HANDLE __stdcall InitializeDevice(unsigned

Self-Hosted WCF Service for 32 bit dll access

馋奶兔 提交于 2019-12-06 13:17:34
I have a Visual Studio Solution for a Windows Forms application with some Class Libraries that are my Application Modules. My application run under "Any CPU" and can't be changed to "x86" because it uses lots of 64 bit dll references. I have a Native C++ 32 bit dll that I need to use inside of one of the app modules but it's quite impossible and dont want to use Wrappers, so I have read that the easiest is to use a Self-Hosted WCF Service. The approach that I was thinking is to create a Console Application (32 bit) project, that will be referencing the Native C++ 32 bit dll, within my solution

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

白昼怎懂夜的黑 提交于 2019-12-06 13:02:35
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 { public float x; public float y; }; private ArrayList DoPolygonOperation() { IntPtr currentVertex =