I have a function that returns a array of 6 doubles.
double* Validation();
I would like to cast this return value in managed code.
array<double>^ validationPosition = gcnew array<double>(6);
validationPosition = Validation();
I get this error:
error C2440: '=' : cannot convert from 'double *' to 'cli::array<Type> ^'
How should ...
The windows forms control library project (C++) I writes uses an unmanaged dll. The unmanaged dll has a header file (a Cheshire cat). And I just include it in the control library project. And calls functions in the unmanaged dll (of course with proper marshaling). This compiles and builds. The problem is when I go ahead to add the contro...
Hi,
i have in fact two unamaged c++ libraries, one of them makes use of the other. Both are pretty big, so rewriting is not an option for me.
I read some stuff about creating a managed c++ library which wraps arround the unmanaged code. But I don't realy get how to get started, and how to combine all this stuff in one Project...
are th...
I have a function in unmanaged C/C++ code (dll) that returns a structure containing a char array. I created C# struct to receive this return value uppon calling the function. And uppon calling this function i get 'System.Runtime.InteropServices.MarshalDirectiveException'
This is C declaration:
typedef struct T_SAMPLE_STRUCT {
int num;
...
An unmanaged C++ dll has an exported function, that takes an int type as window hanlde
void SetWindowHandle(int nHandle);
else where in the unmanaged dll code the int is casted to HWNDand is used properly.
And from the windows forms application, I set the handle as follows
_hHandle = this->Handle.ToInt32();
m_pViewer->SetWindowHandl...
I have the following C-code signature in a dll:
extern __declspec(dllexport) unsigned char *
funct_name (int *w, int *h, char **enc, int len, unsigned char *text, int *lp, int *mp, int *ep)
The C function can modify w, h, enc, lp, mp, and ep (though the latter three can be null and it won't do anything.
I'm using the following in C#
...
Hi all,
I'm trying to learn how to use managed/unmanaged code interop, but I've hit a wall that 4 hours of googling wasn't able to get over. I put together 2 projects in visual studio, one creating a win32 exe, and one creating a windows forms .NET application. After a bunch of mucking around I got the C# code to call into the c++...
I have heard that C++ offers no native support for multithreading. I assume that multithreaded C++ apps depended on managed code for multithreading; that is, for example, a Visual C++ app used MFC or .NET or something along those lines to provide multithreading capability. I further assume that some or all of those managed-code capabil...
Hi,
On the Media Foundation SDK there is the GetPhysicalMonitorsFromHMONITOR function
that I am trying to implement using C# but with no luck ...
In the returned PHYSICAL_MONITOR[], the function returns the string description of the monitor but for some mysterious reasons, the hPhysicalMonitor handle remains at 0.
I have generated the...
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...
I made a static library in Visual C++ 2008 Express Edition. It compiles to Win32 code in a file called static.lib. The functions in this library call SetLastError() to indicate errors or success.
I have already succeeded in including this static.lib in a C++ Win32 DLL, and calling the DLL from C# using p/invoke and DllImport and SetLa...
Setup:
I have a COM DLL that calls a method inside a managed C# DLL. This function returns a C# string[] array, which is marshaled to a SAFEARRAY.
Problem:
When I try to access the strings within the safearray I only get the first char of the string. What am I doing wrong?
The code:
// Pointer to the managed interface
Databa...
I am working on porting some C++ code to managed .NET. I will need to retain some C++ code in native form, and trying to use an IJW approach to it. I know it's possible to declare an unmanaged struct so that it will get correctly marshaled to .NET code, but C++ compiler doesn't seem to do it.
For example I have this code (managed):
str...
I have an unmanaged C++ exe that I could call from inside my C# code directly (have the C++ code that I could make a lib) or via spawning a process and grabbing the data from the OutputStream. What are the advantages/disadvantages of the options?
...
I'm new to Visual C++, .NET, and the Windows world of programming (coming from Objective-C/Cocoa), and I'm trying to use the CFLite (Open CoreFoundation Lite) library, which I compiled to a .lib file. It's written in pure, unmanaged C, and I'd like to use it in my managed CLR .NET app. When I try to link it and use the function CFSTR, wh...
***Platform: in Vista(ultimate or home/premium) it does not work, other OS(xp, windows7) it works******
I'm emptying recycle bin using c++.net(or c#.net) inside a thread. When i do this straight (without thread) it works. But if thread used it doesn't. Please watch the code snippet below:
namespace EmptyRecycleBin_C{
enum RecycleFlags
...
The case:
There is a .net application calling unmanaged C code. Used method for this:
public static class MiracleCreator
{
[DllImport("Library.dll")]
private static extern void RunUnmanaged(string fileName);
public static void Run(string fileName)
{
RunUnmanaged(fileName);
}
}
It is used in a Windows Form...
Hi, is it possible to call C++ code, possibly compiled as a code library file (.dll), from within a .NET language such as C#?
Specifically, C++ code such as the RakNet networking library
Would really appreciate it if anyone could give me some pointers on how to do this/point me in the general direction to get started doing this and I ...
I'm having some trouble finding the syntax for making function calls to unmanaged DLLs in VB.NET. Is anyone familiar with this?
Let's just assume there's a function "Connected" in unmanaged DLL "Connector.DLL". I want to call this function by creating an abstract function call to it.
I've seen some code out there that looks something l...
I have this piece of code (from the nokia pc connectivity 3.2 example code, in C#)
DAContentAccessDefinitions.CA_FOLDER_INFO folderInfo =
new DAContentAccessDefinitions.CA_FOLDER_INFO();
folderInfo.iSize = Marshal.SizeOf(folderInfo); //(32)
IntPtr bufItem = Marshal.AllocHGlobal(folderInfo.iSize);
//I often get a AccessViolat...