unmanaged

Call C# dll from unmanaged C++ app without COM

岁酱吖の 提交于 2019-11-29 22:24:01
问题 Is there a way to call c# dll from c++ unmanaged application without COM usage? 回答1: You can do this using Reverse P/Invoke - example and discussion here. 回答2: It is actually possible to disassemble, modify the IL, and reassemble it with exported functions. I messed with this a few years ago, and created an application that would disassemble a dll, provide a list of functions that could potentially be exported - allowing the user to select them, then re-write the IL and reassemble everything.

Merge several native DLLs into one DLL

[亡魂溺海] 提交于 2019-11-29 19:11:43
问题 I've got a lot of small DLLs which I would like to make into one big(er) DLL (as suggested here). I can do so by merging my projects but I would like a less intrusive way. Can several DLLs be merged into one unit? A quick search found this thread that claims this is not possible. Does anyone know otherwise? Note that I'm talking about native C++ code not .NET so ILMerge is out. 回答1: I don't know about merging dlls, but I'm sure you can link the intermediate object files into one dll. This

Including headers from an unmanaged C++ code inside C++/CLI code

青春壹個敷衍的年華 提交于 2019-11-29 18:02:01
I'm writing a CLR wrapper for an unmanaged C++ library. There are two files I'm including from the unmanaged lib: //MyCLIWrapper.h #include "C:\PATH\TO\UNMANAGED\Header.h" #include "C:\PATH\TO\UNMANAGED\Body.cpp" Then I'm writing CLI implementations for the unmanaged library functions: //MyCLIWrapper.h // includes ... void MyCLIWrapper::ManagedFunction() { UnmanagedFunction(); // this function is called successfuly } However, if my Unmanaged function contains calls to other functions that are defined in other unmanaged header files. This causes a compiler linkage error. If I add includes to

Set Windows Service Description in C++

可紊 提交于 2019-11-29 17:17:30
问题 I am using CreateService to installs a Windows Service executable however I can't seem to find out how to set the description for the service. Does anyone know how to do this? Thanks. 回答1: Call ChangeServiceConfig2 passing SERVICE_CONFIG_DESCRIPTION as the dwInfoLevel parameter. You will also need a handle to the service, but CreateService gives you one of those. SERVICE_DESCRIPTION description = { L"The service description" }; ChangeServiceConfig2(hService, SERVICE_CONFIG_DESCRIPTION,

Passing char pointer from C# to c++ function

时光怂恿深爱的人放手 提交于 2019-11-29 14:55:41
I am stuck in c# implementation side, as I am pretty new to it. The thing is, I want to pass a 'pointer'(having memory) from c# code so that My c++ application can copy pchListSoftwares buffer to pchInstalledSoftwares. I am not able to figure out how to pass pointer from c# side. native c++ code(MyNativeC++DLL.dll) void GetInstalledSoftwares(char* pchInstalledSoftwares){ char* pchListSoftwares = NULL; ..... ..... pchListSoftwares = (char*) malloc(255); /* code to fill pchListSoftwares buffer*/ memcpy(pchInstalledSoftwares, pchListSoftwares, 255); free(pchListSoftwares ); } Passing simple

How to find a child of a parent unmanaged win32 app

天大地大妈咪最大 提交于 2019-11-29 12:43:20
Basically I am looking for a win32 method to invoke in C# to set the focus to a children of an unmanaged application. But first I need to find the child control's handle which is the problem. Any useful win32 functions to solve this? There is a library which supports enumerating and searching window handles, which is available at http://mwinapi.sourceforge.net/ Just so that you do not have to reinvent the wheel every time ;) Start with SystemWindow.AllToplevelWindows and then just dig your way down (looking at class names, process names, titles, dialog IDs, whatever). Use FindWindowEx to find

Pass a function pointer from C++ to be called by C# - Arguments of functions include a wide char string (LPCWSTR)

谁都会走 提交于 2019-11-29 11:37:07
I am writing a C# library to be used by native C++ application. I am using C++/CLI as the Interoperability mechanisim. I require to pass a callback function from C++ to C# (using C++/CLI as the intermediate layer). C# library needs to call the C++ function with a zero terminated string of wide characters; i.e. the prototype of the callback function is Func(LPCWSTR pszString); There are other parameters but they are immaterial for this discussion. I searched net and found Marshal.GetDelegateForFunctionPointer Method wich I can use. The problem with this is that it converts System.String from C#

.NET System::String to UTF8-bytes stored in char*

拈花ヽ惹草 提交于 2019-11-29 10:50:49
I am wrapping some unmanaged C++ code inside a .NET project. For this I need to convert System::String to UTF8-bytes stored in char* . I am unsure if this is the best or even a correct way to do this and I'd appreciate if someone could take a look and provide feedback. Thanks, /David // Copy into blank VisualStudio C++/CLR command line solution. #include "stdafx.h" #include <stdio.h> using namespace System; using namespace System::Text; using namespace System::Runtime::InteropServices; // Test for calling with char* argument. void MyTest(const char* buffer) { printf_s("%s\n", buffer); return;

Read cell Items from data grid in SysListView32 of another application using C#

只愿长相守 提交于 2019-11-29 08:42:37
I am trying to read data grid items in SysListView32 of another process using C# .net ui-automation and winapi C# code using ui-automation http://pastebin.com/6x7rXMiW C# code using winapi http://pastebin.com/61RjXZuK using this code you just have to place your Mouse pointer on SysListView32 on screen and press Enter. now both code returns empty on the cell item which have following properties pastebin.com/Rw9FGkYC but both code works on following properties pastebin.com/L51T4PLu the only difference i noted that the name property contains the same data as in cell but problem occurs when name

How to generate type library from unmanaged COM dll

ぃ、小莉子 提交于 2019-11-29 06:58:45
问题 I have to use third party, unmanaged COM dll into my .NET application. I need to modify this assembly to produce a custom RCW. In order to Edit Interop Assembly I need the type library of the particular assembly. Can any one explain me that how to How to generate type library from unmanaged COM dll? There is no option in regsvr32 to generate type library. Thank you, Best Regards, Robo. 回答1: If all you're trying to do is create an Interop Assembly from a native dll (and the native DLL embeds