dllimport

Using kernel32 CreateThread/TerminateThread inside Azure Worker Role

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 17:25:11
问题 I have this code that I need to use, but what holds me back is that here it says that TerminateThread Applies to: desktop apps only . I wonder if I can use this code inside azure Worker role, specifically inside waiishost.exe process that I use to run the Worker thread in? [DllImport("Library.dll")] public static extern void InfiniteLoop(); [DllImport("kernel32")] private static extern int CreateThread( IntPtr lpThreadAttributes, UInt32 dwStackSize, IntPtr lpStartAddress, IntPtr param, UInt32

How to share a class in a Visual C++ DLL with C#?

独自空忆成欢 提交于 2019-12-24 11:58:35
问题 I wrote my program in C++ and exported it as a DLL. I have a C# WPF GUI and I want to import the DLL to do the processing. I am very new to C#. How can I use the C++ class in C#? I know I can't just use the .h file. Because I used pointers in C++, in C# I couldn't use pointers. That's why I got confused. Like in C++ i used char* instead of string , and I need to return double* for a big collection of double data, and things like that. 回答1: There are a number of ways: Export the DLL functions

Export DLLs classes and functions and import them into Win32 Application

百般思念 提交于 2019-12-24 09:26:19
问题 I have a dll with a class that define some methods and variables inside it. I marked it as __declspec(dllexport) and i imported the .h header inside a win32 application project in the same solution. I can use the functions but when I try to compile the project I have a lot of errors about external symbols not resolved. Why? 回答1: Please read about the standard way of using macros for this very common task here: http://wiki.tcl.tk/8721 The basic idea is that you define a macro, say MY_API like

Calling OpenGL functions in C# using DllImport?

馋奶兔 提交于 2019-12-24 07:29:43
问题 I'm working on a C# utility library for OpenGL at the moment. For cross platform window management I use GLFW and I got functions like glfwCreateWindow or glfwMakeContextCurrent loaded successfully with DllImport. Now I want to use OpenGL and since I've mostly worked with GLEW in the past I decided to use it for my C# project as well. So I tried to use DllImport for glewInit and that worked. But when I try to do the same thing for OpenGL functions such as glClear I get an error saying that it

Correct use of SafeHandles in this P/Invoke use case

橙三吉。 提交于 2019-12-24 06:03:58
问题 Working in C# with a native Dll, that uses opaque handles and internal reference counting, I have the following P/Invoke signatures (all decorated with DllImport attribute) [DllImport("somedll.dll"] public extern IntPtr getHandleOfA(IntPtr handleToB, int index); //(1) public extern IntPtr makeNewHandleOfA(); //(2) public extern void addRefHandleToA(IntPtr handleToA); //(3) public extern void releaseHandleToA(IntPtr handleToA); //(4) public extern void doSomethingWithHandle(IntPtr handleToA) /

Trouble loading Unmanaged C++ DLL from WPF application

隐身守侯 提交于 2019-12-24 05:52:40
问题 First of all I would like to thank anyone reading this for their time! I'm a pretty well-informed C# programmer with WinForms and I'm giving WPF a shot. I've been having trouble calling functions from my WPF application so I decided to create a very easy example project to illustrate my problem. In this application I'm creating a C++ Dll (using Visual Studio 2012 -> Visual C++ -> Win32 Console Application -> .DLL Project). In this DLL, I'm simply creating a function to return a DWORD. My DLL

DLLImport with char * arguments. Only one character being passed

落花浮王杯 提交于 2019-12-24 02:08:03
问题 I have written a C++ DLL with the following function exported extern "C" BOOL WINAPI SetUserPassword(const char* u, const char* p) When calling this from C# I am using the following code [DllImport("mydll.dll")] private static extern int SetUserPassword(String user, String password); Now when SetUserPassword is called I only get the first letter of each parameter. I did some googling and found that String was perhaps not the best to use so tried using IntPtr and Marshal.StringToBSTR() but

Getting InteropServices.SEHException on DllImport routine during debug after migrating project from .NET Framework 3.5 to 4.0

ⅰ亾dé卋堺 提交于 2019-12-24 01:55:25
问题 I have written an application that interfaces with the winspool print driver, and its been working just fine for months. I need to move my projects from .NET Framework 3.5 to 4.0 to include a coworkers assemblies, but doing this (and only doing this) causes one of my .dll imported method calls to fail when executing from the VS 2010 IDE. Both the debug and release binaries still work if I run them outside of the Visual Studio 2010 environment. Below is the line that now fails after moving to

Using custom dll in Qt Application

牧云@^-^@ 提交于 2019-12-24 01:16:33
问题 First, my compiler and OS: Qt Creator 1.3 Qt 4.6 (32 bit) Windows 7 Ultimate I want to learn how to create and import a dll in Qt. I've created a *.dll file using Qt Creator, called Shared1.dll which contains nothing but an empty class named Shared1 . Now I'd like to use Shared1 class in another Qt project. How can I do that? Thanks in advance. 回答1: Use your Pro file to include your header files and libraries.. For Header Files: INCLUDEPATH += "C:\Source\HeaderFiles" For libraries: LIBS += "C

Using DLLImport to import an Object

非 Y 不嫁゛ 提交于 2019-12-24 00:45:41
问题 I have a dll for a c++ class (SLABHIDDevice.dll). I am trying to use the functions of this dll in a C#.net application. The dll contains several methods which I can use easily with statements such as this... (I appolagize if i get some of the terminology wrong here I am new to using dlls) [DllImport("SLABHIDDevice.dll")] public static extern byte GetHidString (Int32 deviceIndex, Int32 vid, Int32 pid, Byte hidStringType, String deviceString, Int32 deviceStringLength); The documentation for