unmanaged

Marshaling byval C-structure as return value in C#

丶灬走出姿态 提交于 2019-12-07 09:00:01
问题 I have unmanaged code: ... typedef struct foo { int a; bool b int c; } FOO,*LPFOO; .... __declspec(dllexport) FOO __stdcall GetFoo() { FOO f; <some work> return f; } .... I've declare C# prototype for GetFoo function: [StructLayout(LayoutKind.Sequential, Pack = 1)] private struct Foo { public int a; public bool b public int c; }; [DllImport("foo.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] [return:MarshalAs( UnmanagedType.Struct)] private static extern Foo

Unmanaged memory not showing up in task manager

 ̄綄美尐妖づ 提交于 2019-12-07 06:41:40
问题 I wrote the following test (actually used in a wider context) IntPtr x = Marshal.AllocHGlobal(100000000); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); Marshal.FreeHGlobal(x); Console.ReadKey(true); Why doesn't the task manager show any sign of the allocated 100 megabytes before the first key press? If this is by design, how else can I test the consumption of unmanaged heap memory? 回答1: You are getting some insight in how your operating system works. This behavior

64 bit managed assembly with unmanaged dependencies not loading in IIS / ASP.NET MVC 4

混江龙づ霸主 提交于 2019-12-07 06:08:56
问题 I have an almost empty ASP.NET MVC4 project referencing a 64 bit managed assembly, which has a set of unmanaged dependencies. The managed assembly is referenced the normal way through references. The unmanaged dependencies are copied to the bin folder on a post build event - and are present when the web app is started (this has been verified). The problem is that I get: Could not load file or assembly 'msvcm80.DLL' or one of its dependencies. A dynamic link library (DLL) initialisation

How do I strongly name an Unmanaged C++ Dll?

安稳与你 提交于 2019-12-07 05:57:00
问题 I'm working on a C# application which uses the EasyHook library for DLL Injection. EasyHook requires that any application using it be strongly named. In order to strongly name the application I need to make sure that all the libraries I use are strongly named as well. This is easy to do for all of my managed libraries, but I also have an unmanaged c++ library which I need to strongly name. After some searching I can't seem to find a way to sign my unmanaged dll, even with the source code. Can

HOWTO: Call Managed C# Interface From Unmanaged C++ On WindowsCE Compact Framework

十年热恋 提交于 2019-12-07 03:54:25
问题 I have extensive unmanaged Windows CE 5 C++ code that provides a UI that I want to use in a new product by combining it with a large amount of newer business and communications logic written in managed C# on Windows CE 6 and the Compact Framework. The UI may know about the business logic, but I want the business logic ignorant of the UI such that I can later replace it with a managed version, or any other UI that I choose as a front-end. I found an article that describes how to use COM as the

Using unmanaged code from managed code

瘦欲@ 提交于 2019-12-07 02:25:48
问题 I have my project developed in MFC which is unmnaged code. Now i need to create a similar application in C#, by reusing most of the MFC classes. Is it possible to directly export class/struct/enum from MFC dll, so that i can import it in my C# using dllimport and use it.? 回答1: Yes, it is quite possible. You just need to be careful with the types. Many translate very nicely but some are quirky. The name of the concept you're searching for is COM interop. See here for a getting started tutorial

Default Printer in Unmanaged C++

一曲冷凌霜 提交于 2019-12-07 00:38:33
I'm looking for a way to find the name of the Windows default printer using unmanaged C++ (found plenty of .NET examples, but no success unmanaged). Thanks. Doug T. The following works great for printing with the win32api from C++ char szPrinterName[255]; unsigned long lPrinterNameLength; GetDefaultPrinter( szPrinterName, &lPrinterNameLength ); HDC hPrinterDC; hPrinterDC = CreateDC("WINSPOOL\0", szPrinterName, NULL, NULL); In the future instead of googling "unmanaged" try googling "win32 /subject/" or "win32 api /subject/" Here is how to get a list of current printers and the default one if

What is an un/managed DLL? What is un/managed code? [duplicate]

烂漫一生 提交于 2019-12-06 20:19:02
问题 This question already has answers here : What is managed or unmanaged code in programming? (13 answers) Closed 6 years ago . Could someone please explain to me what an un/managed DLL is? And what is un/managed code? 回答1: You will get a fair idea on managed and unmanaged code in following article - http://www.developer.com/net/cplus/article.php/2197621/Managed-Unmanaged-Native-What-Kind-of-Code-Is-This.htm 回答2: Unmanged code will be compiled to machine language to run directly on the hardware.

How is it that a struct containing ValueTuple can satisfy unmanaged constraints, but ValueTuple itself cannot?

青春壹個敷衍的年華 提交于 2019-12-06 19:39:12
问题 Consider the following types: (int, int) → managed. struct MyStruct { public (int,int) Value; } → unmanaged! Problem: A non-generic structure MyStruct , which has a managed member (int,int) has been evaluated as managed type. Expected Behavior: A structure which contains a managed member, should be considered as managed, the same way the struct MyStruct { int? Value; } are considered as managed. It seems both types are behaving against the documentations [1] and [2]. Example 1 - unmanaged

ITaskbarList3 undeclared?

五迷三道 提交于 2019-12-06 14:56:35
I'm trying to write some c++ code to use the ITaskbarList3, but I'm getting that error. I have confirmed that I am including shobjidl.h (but I checked and this file only defines up to ITaskbarList2). I have Visual Studios 2008 (SP1) and I have Microsoft Windows SDK for Windows Server 2008 installed. Does anyone know what I am missing? You need to install the Windows 7 SDK . That has an update shobjidl.h with ITaskbarList3. Or you can adapt the content of Windows 7 SDK related to ITaskbarList3 from the shobjidl.h into your code as virtual methods, don't forget their GUID you have to be careful