473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

passing unmanaged pointers

I have two unmanaged pointer in a managed form class:

IDirect3D9* d3dObject;
IDirect3DDevice9* d3dDevice;

In a member function of the form, I call:

d3dObject->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
(HWND)hwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
d3dPP,
&d3dDevice));

I get the error:

error C2664: 'IDirect3D9::CreateDevice' : cannot convert parameter 6 from
'cli::interior_ptr<Type>' to 'IDirect3DDevice9 **'
with
[
Type=IDirect3DDevice9 *
]
Cannot convert a managed type to an unmanaged type
Feb 14 '06 #1
1 2357
IDirect3D9* d3dObject;
IDirect3DDevice9* d3dDevice;
In a member function of the form, I call:

d3dObject->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
(HWND)hwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
d3dPP,
&d3dDevice));

I get the error:

error C2664: 'IDirect3D9::CreateDevice' : cannot convert parameter 6 from
'cli::interior_ptr<Type>' to 'IDirect3DDevice9 **'
with
[
Type=IDirect3DDevice9 *
]
Cannot convert a managed type to an unmanaged type


have a look at
http://www.codeproject.com/managedcp...orpointers.asp
http://www.codeproject.com/managedcp...edpointers.asp

<quote>
from the article text:
You can see how we can pass both interior pointers as well as native
pointers to the same function; this is because native pointers automatically
convert to interior pointers. [Note that interior pointers cannot convert to
native pointers]
</quote>

I don't have the D3D SDK on my machine, but I can do something like this in
a managed app:

#pragma unmanaged
class Test
{
public:
int j;
Test(int i)
{
j=i;
}
};
void fun(Test ** item)
{
*item = new Test(1);
}
#pragma managed

//managed code here
Test* bla;
pin_ptr<Test*> pptr = &bla;
fun(pptr);

another solution is to wrap all your unmanaged D3D stuff in a wrapper class
that keeps all unmanaged stuff inside.
Note: I was able to compile my example with and without pinning the pointer,
so I don't know why your situation is different.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
2
by: Sasha Nikolic | last post by:
I have one unmanaged and one managed class in the same vc++ project. Managed object creates one instance of unmanaged class and needs to pass a callback reference so that unmanaged class can...
3
by: Sam Carleton | last post by:
I am writing Managed C++ code to call in to an Unmanaged C API. The reason for using Managed C++ over C# is that the Unmanaged C module is loaded via LoadLibrary(). DllImport cannot be used;...
6
by: marek | last post by:
Hello All, we are doing a quite a big project that contains at the lowest level an unmenaged c++ classes. Above it there are managed wrappers and at the top there are ASP.NET pages. Can anyone...
4
by: Maxwell | last post by:
Hello, Newbie question here for disposing of unmanaged resources in MC++.NET. I have a managed VS.NET 2003 MC++ wrapper class that wraps a unmanaged C++ dll. What I am trying to figure out is...
15
by: John Alway | last post by:
Hello, I'm using a DLL I wrote in C++, and am attempting to call and use it from VB. This works fine for functions where I pass parameters by value, but I can't get pointers to work. I get...
4
by: Andreas Reiff | last post by:
Hi! I want some communication to take place between a c++ app and a c++ .dll with an intermediate managed/unmanaged c++ dll. Basicall, I want the unmanaged c++ dll to have a callback to the...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
0
by: mjaaland | last post by:
Hi! I've been working with DLLimports passing structs and various other parameters to unmanaged code. I had problems earlier sending pointer to structs to the unmanaged code, and this forum solved...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.