dllimport

A call to PInvoke has unbalanced the stack… dll import fails even with Cdecl

孤街醉人 提交于 2019-12-10 21:30:48
问题 Aha, this question is all over stack overflow so I've already proceeded to add CallingConvention = CallingConvention.Cdecl which has worked just fine for other libraries I've had to import but in this case, nothing changes and it still fails with the same error message. The original code for this came out of a .net 3.5 project and works perfectly fine: [DllImport("Compiled DSP.dll")] private static extern int fnGetConfigParam(int nID, ref stParamInt pstParam); [DllImport("Compiled DSP.dll")]

Importing c++ dll in c# project

天涯浪子 提交于 2019-12-10 16:06:58
问题 I am importing some c++ dll into a c# project, I am using visual studio 2010. I have succeded to import function that are using built-in type, however I am getting error when I have tried to deal with structure. This is a simple example: c++ code typedef long int TDate; typedef struct _TMDYDate { long month; /* In range [1,12] */ long day; /* In range [1-31] */ long year; /* In range [1600-] */ } TMonthDayYear; int JpmcdsDateToMDY (TDate date, /* (I) TDate format */ TMonthDayYear *mdyDate);

DllImport on c#

非 Y 不嫁゛ 提交于 2019-12-10 15:34:36
问题 How do I access the functions of a C++ DLL in C# Here are the prototypes from the DLL: NOMANGLE int CCONV SSPSendCommand (SSP_COMMAND * cmd, SSP_COMMAND_INFO * sspInfo); NOMANGLE int CCONV OpenSSPComPort (SSP_COMMAND * cmd); NOMANGLE int CCONV OpenSSPComPort2 (SSP_COMMAND * cmd); NOMANGLE int CCONV OpenSSPComPortUSB (SSP_COMMAND * cmd); NOMANGLE int CCONV CloseSSPComPort (void); NOMANGLE int CCONV CloseSSPComPort2 (void); NOMANGLE int CCONV CloseSSPComPortUSB (void); NOMANGLE int CCONV

DUMPBIN utility mangled name output

眉间皱痕 提交于 2019-12-10 15:20:58
问题 I am using DUMPBIN utility for getting mangled name from a c++ dll to use in a c# application . I am exposing a c++ class member function using __declspec(dllexport) and the output mangled name result is the folowing ?InitPort@CProtocolStack@@QAEEHEPAEKE@Z = ?InitPort@CProtocolStack@@QAEEHEPAEKE@Z (public: unsigned char __thiscall CProtocolStack::InitPort(int,unsigned char,unsigned char *,unsigned long,unsigned char)) Do I need to use the whole name in C# application while importing the same

How to determine if the Caps Lock is toggled in a Silverlight Application?

非 Y 不嫁゛ 提交于 2019-12-10 13:54:44
问题 In a Silverlight application's log in screen, i need to determine if Caps Lock is toggled. This is easy enough by handling the KeyUp or KeyDown event, however how does one determine if it is toggled on or off even if a key hasn't been pressed? The reason I want todo this is what if the user doesn't press Caps Lock while the Silverlight application is running, but rather they toggled it before they even got to the login screen? I need to still warn them that caps Lock is on. Apparently

DLLImportAttribute C# - Outlook

不羁岁月 提交于 2019-12-10 12:33:53
问题 I'm trying to develop a snippet in C # code that enables the "voting option" function of Outlook. This code will be used by a platform called Blue Prism. The "vote" function of Outlook is in the Microsoft.Office.Interop.Outlook namespace, so I need to import it using C#, but I dont have enough knowledge to develop this. I tried to do something like this but it is giving an error. Here is the code: public class program { [DllImport(@"C:\Program Files\Blue Prism Limited\Blue Prism Automate

GetMessage() given an System.ExecutionEngineException

一个人想着一个人 提交于 2019-12-10 12:12:33
问题 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Diagnostics; using System.Threading; namespace WindowsFormsApplication1 { public partial class Form1 : Form { [DllImport("user32.dll")] public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, int vk); [DllImport("user32")] public static

Passing String from Native C++ DLL to C# App

£可爱£侵袭症+ 提交于 2019-12-10 10:49:47
问题 I have written a DLL in C++. One of the functions writes to a character array. C++ Function EXPORT int xmain(int argc, char argv[], char argv2[]) { char pTypeName[4096]; ... //Other pTypeName ends up populated with "Portable Network Graphics" //This code verifies that pTypeName is populated with what I think it is: char szBuff[64]; sprintf(szBuff, pTypeName, 0); MessageBoxA(NULL, szBuff, szBuff, MB_OK); //The caption and title are "Portable Network Graphics" ... //Here, I attempt to copy the

Self-Hosted WCF Service for 32 bit dll access

ε祈祈猫儿з 提交于 2019-12-10 10:49:35
问题 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

struct remains unaltered after passing by reference into unmanaged C DLL function

戏子无情 提交于 2019-12-10 10:30:08
问题 I'm writing a wrapper in C# for an unmanaged C DLL. In the DLL I have the following method which returns pointer struct (struct code near end of post): struct zint_symbol *ZBarcode_Create() { struct zint_symbol *symbol = (struct zint_symbol*)calloc(1, sizeof(struct zint_symbol)); if (!symbol) return NULL; symbol->symbology = BARCODE_CODE128; strcpy(symbol->fgcolour, "000000"); strcpy(symbol->bgcolour, "ffffff"); strcpy(symbol->outfile, "out.png"); symbol->scale = 1.0; symbol->option_1 = -1;