dllexport

Returning struct from c++ dll to Python

余生颓废 提交于 2020-01-05 07:06:11
问题 I'm trying to return structure so I can use it in Python. I am beginner programmer so please explain me what am I doing wrong. I've succeeded to return simple ctypes earlier (bool, unsigned int) but struct is too complicated for me. This is what I have: DLLAPI.h #define DLLAPI extern "C" __declspec(dllexport) ... DLLAPI myStruct* DLLApiGetStruct(); DLLAPI.cpp EDIT1: instead of TString, struct members type is wchar_t* now, but error I get is the same ... typedef struct myStruct{ wchar_t* id;

How to pass a String to const char * from VB.NET to a DLL programmed in C++

守給你的承諾、 提交于 2020-01-05 05:42:27
问题 I have created a C++ exported function this way: extern "C" __declspec(dllexport) int __stdcall AlmacenarPedidoLipigas(const char * pszTelefono, const char * pszFechaPedido, const char * pszHoraPedido, const char * pszCodigoInterno, const char * pszDescripcionProducto, const char * pszCantidadProducto, const char * pszValorUnitario, const char * pszFechaEntrega, const char * pszHoraEntrega, const char * pszKilosProducto, const char * pszFechaDespacho, const char * pszHoraDespacho) On the

C# Implementing DllMain with DllExport

旧街凉风 提交于 2020-01-05 05:27:08
问题 I'm using UnmanagedExports By RobertGiesecke I want to export DllMain entrypoint. Here what I've tried [DllExport("DllMain", CallingConvention.StdCall)] public static bool DllMain(IntPtr hModule, uint dwReason, byte[] lpReserved) { // I Write a text to file here return true; } Then I call LoadLibrary but nothing happens. Any solution? 回答1: Hooray, I found a way by using static constructor. Just make class that contains exports static, and add static method. public static class Class1 { static

What is dllspec(dllimport) and dllspec(dllexport) means

半世苍凉 提交于 2020-01-01 00:49:08
问题 After googling, i came to know that Dllimport makes the function available for other modules, is it mandatory to declare function with extern "c" identifier? Also, Dllexport means, Dll itself uses the function while compiling it says. so by default all functions present in DLL are dllexport? 回答1: __declspec(dllexport) exports a symbol. It makes it available from outside a DLL. __declspec(dllimport) imports a symbol. It practically says "this symbol is not defined in this application, it needs

Sharing variables between multiple Dlls in C++

主宰稳场 提交于 2019-12-25 07:54:23
问题 I need to share a variables (1000s) between 2 C++ Dlls. How should I do that? MyVariables.Dll contains: int a = 0; ModifyMyVariables.Dll contains: extern int a; a++; // do more stuff with a; What am i supposed to write in the following files? myvariables.h myvariables.cpp ModifyMyVariables.h ModifyMyVariables.cpp 回答1: You can share data between images (EXE, DLL...) using several fundamental mechanisms (using extern does not work to share data - it only instructs the linker and not the loader!

How to implement a class counter in DLL?

旧巷老猫 提交于 2019-12-25 03:24:40
问题 So far I have: // TypeCounter.h template <typename Base> class Counter : public Base { protected: static int typeIndexCounter; }; template <typename T, typename Base> class Bridge : public Counter<Base> { public: virtual ~Bridge() {} virtual int GetTypeIndex() const { return TypeIndex(); } static int TypeIndex() { static int typeIndex = typeIndexCounter++; return typeIndex; } }; // static variable definition template <typename Base> int Counter<Base>::typeIndexCounter; Use case is like: class

Resolve Function Address with PE Export Table

∥☆過路亽.° 提交于 2019-12-24 17:48:49
问题 Can anyone explain me how to properly obtain a function address from a PE image and then call that function with a delegate? I found a good piece code googling around that loads exports from a DLL library, but it only get function names out of it... so I modified it as follows: [DllImport("ImageHlp", CallingConvention = CallingConvention.Winapi), SuppressUnmanagedCodeSecurity] public static extern bool MapAndLoad(string imageName, string dllPath, out LOADED_IMAGE loadedImage, bool dotDll,

Heap Violations when releasing a CStringArray& parameter from a DLL exported function

社会主义新天地 提交于 2019-12-24 12:57:20
问题 I have developed a MFC dll containing a function having this prototype: //DLL code long __declspec(dllexport) GetData(CString csIdentifier, CStringArray& arrOfData) { //based on the identifier I must add some strings inside the string array arrOfData.Add("..."); arrOfData.Add("..."); /*.....................*/ return 1; } The problem that I have is after the function gets called (from the executable). The destructor of the arrData will be called and will try to release the memory but it will

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

Why are the exported functions not named properly in the DLL?

佐手、 提交于 2019-12-24 07:31:04
问题 I'm trying to do a little test-plugin using NPAPI for firefox. This is my code so far: /* File: npp_test.cpp Copyright (c) 2012 by Niklas Rosenstein Testing the NPAPI interface. */ // - Includes & Preprocessors -------------------------------------------------- // - -------- - ------------- -------------------------------------------------- #define DEBUG #ifdef DEBUG # include <iostream> using namespace std; # include <windows.h> #endif // DEBUG #include <stdint.h> #include <npapi.h> #include