473,466 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Pinning ref objects

Can this approach pin a ref object, in this case a System::String? (just
because C++ programmers like low level programming and not a language
that tries to protect us from ourselves).
int main()
{
using namespace System;

String ^s="Hello";

pin_ptr<unsigned char> p= *reinterpret_cast<unsigned char **>(&s);
}


--
Ioannis Vranos
Nov 17 '05 #1
1 937
Ioannis Vranos wrote:
Can this approach pin a ref object, in this case a System::String? (just
because C++ programmers like low level programming and not a language
that tries to protect us from ourselves).
int main()
{
using namespace System;

String ^s="Hello";

pin_ptr<unsigned char> p= *reinterpret_cast<unsigned char **>(&s);
}

Or perhaps this style:
value class ValueClass
{};

ref class RefClass{};
int main()
{
using namespace System;

RefClass obj;

ValueClass ^h=reinterpret_cast<ValueClass ^>(%obj);

// obj is pinned
pin_ptr<ValueClass> p= &*h;

// Unpin
p=nullptr;
}


--
Ioannis Vranos
Nov 17 '05 #2

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

Similar topics

2
by: Chris Finlayson | last post by:
Hello: I have a question on pinning types via 'fixed'. In "Com and .NET interoperability" by Andrew Troelsen, he provides a simple example of ..NET -> Native interoperability: int...
3
by: J | last post by:
I understand how to pin pointers as they are declared, but for some reason, I can'f figure out the syntax for predaclaring a pointer and then pinning in afterward like you would if you wanted to...
1
by: demofo | last post by:
Does the pinning pointer safe?since the Read function will change the ppBuffer points to unmanaged C++ heap,how does the dot net runtime knows they will not move the allocated memory (pointed by...
7
by: Ioannis Vranos | last post by:
Consider the code: wchar_t __pin *p= &(someCommand->ToCharArray()); _wsystem(p); p=0;
9
by: Brian Victor | last post by:
I have a situation where I have a vector<gcroot<ManagedWrapperClass*> > whose contents I need to pass to an unmanaged function. Is there a way to pin all the pointers in the vector for that...
3
by: Hexar Anderson | last post by:
I have two questions: a) From documentation located at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/vcManagedExtensionsSpec_7_7.asp, it says, "Pinning a...
5
by: Maxwell | last post by:
Hello, Newbie question here. I have a VS.NET 2003 MC++ (not C++/cli) project where I have a managed class reference in a unmanaged class...simple enough. To keep things short I am for the most...
5
by: _iycrd | last post by:
After numerous problems, I'm having second thoughts about using C++/CLI to wrap a native DLL. On the other hand, PInvoke seems like it will take a huge amount of work, if it will work at all. ...
2
by: steve | last post by:
Hi all, I want to understand more about how the pinvoke pinning process works. I'm writing some code that calls DeviceIoControl. DeviceIoControl provides a generic interface to device drivers....
12
by: DaTurk | last post by:
Hi, I have a rather interesting problem. I have a unmanged c++ class which needs to communicate information to managed c++ via callbacks, with a layer of c# on top of the managed c++ ultimatley...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.