dllimport

Possible to call DLL function in uninstaller if DLL has dontcopy flag?

若如初见. 提交于 2020-08-23 13:02:48
问题 As the title says I need a function in my DLL which I need to call while uninstalling. The DLL is included this way #define myProgData "C:\ProgramData\Foo\Bar" [Files] Source: "mydll.dll"; Flags: dontcopy I already use one function while installing and now I want to know if I can use the same DLL for uninstall or does the DLL have to be copied so the uninstaller can access it? I've tried a simple call already but got the Could not call proc - Exception So I'm looking for the reason for this.

Is there generally a noticeable performance hit when calling PInvoke on Win32 / COM methods?

狂风中的少年 提交于 2020-05-24 10:12:20
问题 I'm wondering whether anyone has a decent explanation or overview on the negative aspects of using DLLImport / PInvoke on Win32 methods from managed .Net code? I plan to make use of various Win32 methods and would like to have a greater understanding on the negative implications of doing so. Thanks, Brian. 回答1: According to MSDN - Calling Native Functions from Managed Code PInvoke has an overhead of between 10 and 30 x86 instructions per call. In addition to this fixed cost, marshaling

Windows Defender Antivirus scan from C# [AccessViolation exception]

自古美人都是妖i 提交于 2020-05-22 11:34:15
问题 We are writing a code to do on-demand scan of a file from C# using Windows Defender APIs. [DllImport(@"C:\Program Files\Windows Defender\MpClient.dll")] public static extern int WDStatus(out bool pfEnabled); [DllImport(@"C:\Program Files\Windows Defender\MpClient.dll")] public static extern int MpManagerOpen(uint dwReserved, out IntPtr phMpHandle); [DllImport(@"C:\Program Files\Windows Defender\MpClient.dll")] public static extern int MpScanStart(IntPtr hMpHandle, uint ScanType, uint

Using dllimport in place of dllexport

走远了吗. 提交于 2020-03-16 08:09:22
问题 I seem to be able to use __declspec(dllexport) and __declspec(dllimport) interchangeably when building my dll in Visual Studio 2015. I would have thought when making the DLL that the dllexport command would have been required but it seems either dllexport or dllimport is adequate.I have the following header file declaring a simple add() functions: add.h #pragma once #ifdef ADDDLL_EXPORTS #define ADDDLL_API __declspec(dllexport) #else #define ADDDLL_API __declspec(dllimport) #endif ADDDLL_API

Shorten amount of DllImport in C#?

允我心安 提交于 2020-02-07 08:26:15
问题 Here is a sample of my C# code. Is there a way to decrease the amount of DllImport attributes? namespace CSLib { class Program { static void Main(string[] args) { CLib.test(); CLib.test2(3); A a = new A() { a = 9, b = 5 }; CLib.test3(ref a); } } class CLib { [DllImport("path/to/CDLL", CallingConvention = CallingConvention.Cdecl)] public static extern void test(); [DllImport("path/to/CDLL", CallingConvention = CallingConvention.Cdecl)] public static extern void test2(int a); [DllImport("path

Import error while trying to run jupyter notebook

只愿长相守 提交于 2020-02-05 13:10:09
问题 An import error occurs when trying to run jupyter notebook I'm trying to run jupyter notebook using anaconda ( git bash platform), and as I type in jupyter notebook, an import error occurs every time. I tried to lauch it inside an environment, but the same error occured. $ jupyter notebook Traceback (most recent call last): File "C:\Users\User\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module> from notebook.notebookapp import main File "C:\Users\User\Anaconda3\lib\site

Import error while trying to run jupyter notebook

早过忘川 提交于 2020-02-05 13:07:50
问题 An import error occurs when trying to run jupyter notebook I'm trying to run jupyter notebook using anaconda ( git bash platform), and as I type in jupyter notebook, an import error occurs every time. I tried to lauch it inside an environment, but the same error occured. $ jupyter notebook Traceback (most recent call last): File "C:\Users\User\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module> from notebook.notebookapp import main File "C:\Users\User\Anaconda3\lib\site

Passing a char array from c# to c++ dll

风格不统一 提交于 2020-02-04 05:06:11
问题 I have a dll of the LZ4 c implementation and I want to call the LZ4_compress_default(const char* source,char* dest,int sourceLength,int maxdestLength); function from a c# code. The function compresses the source array into the dest array. How to do this? My C# code: DllImport(@"CXX.dll", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention = CallingConvention.Cdecl)] internal static extern int LZ4_compress_default( [MarshalAs(UnmanagedType.LPArray)] char[] source, out byte[] dest,

trouble using unmanaged c++ from c# using dllimport

故事扮演 提交于 2020-01-25 21:40:41
问题 i am having trouble importing c++ unmanaged dll into C# [winform]. Can someone help? Basically i am just trying to create a safearray of strings in c++ and trying to send it to C#. Here is my c++ code. extern "C" __declspec(dllexport) BOOL GetStringArr(SAFEARRAY* arr) { SAFEARRAY* myArray; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = 5; myArray = SafeArrayCreate(VT_BSTR, 1, rgsabound); VARIANT* pvData = (VARIANT*)(myArray->pvData); pvData[0].vt = VT_BSTR;

Prevent .lib from loading DLL at runtime

孤者浪人 提交于 2020-01-25 08:49:11
问题 How would I prevent an import lib from loading the DLL it refers to at runtime until I call something like, say, LoadLibrary ? 回答1: Maybe you need this: http://www.west-wind.com/weblog/posts/2007/Dec/02/Delay-Loading-a-DLL-with-a-Linker-Switch-in-Visual-Studio http://www.codeproject.com/Articles/273419/Dynamic-Libraries-with-Delayed-Function-Loading 来源: https://stackoverflow.com/questions/12685664/prevent-lib-from-loading-dll-at-runtime