473,406 Members | 2,710 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,406 software developers and data experts.

Creating a HANDLE[] in a managed class

Jon
Hi

I've created a HANDLE[] in a managed class:

pHandle = new HANDLE[2];

where pHandle is HANDLE* defined in my __gc class

Is this an unamanged or a managed pointer? I would have thought it would be
unmanaged but I can __pin it, which implies it is managed.

Help appreciated.

Thanks

Jon
Nov 17 '05 #1
2 917
Jon,

I've created a HANDLE[] in a managed class:

pHandle = new HANDLE[2];

where pHandle is HANDLE* defined in my __gc class

Is this an unamanged or a managed pointer? I would have thought it would be unmanaged but I can __pin it, which implies it is managed.


That depends on how you look at it:
The memory referenced by pHandle is *unmanaged*, since it is stored in the
CRT heap. However, the memory pHandle itself is stored is actually in the GC
heap, since it is part of a reference object.

If you needed to pass &pHandle to an unmanaged function, then you'd
certainly need to pin it first...

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2
Jon
Thanks Tomas

.......question answered perfectly. The light is now on!

Jon

"Tomas Restrepo (MVP)" wrote:
Jon,

I've created a HANDLE[] in a managed class:

pHandle = new HANDLE[2];

where pHandle is HANDLE* defined in my __gc class

Is this an unamanged or a managed pointer? I would have thought it would

be
unmanaged but I can __pin it, which implies it is managed.


That depends on how you look at it:
The memory referenced by pHandle is *unmanaged*, since it is stored in the
CRT heap. However, the memory pHandle itself is stored is actually in the GC
heap, since it is part of a reference object.

If you needed to pass &pHandle to an unmanaged function, then you'd
certainly need to pin it first...

--
Tomas Restrepo
to****@mvps.org

Nov 17 '05 #3

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

Similar topics

4
by: Terry | last post by:
There are a number of things about using unmanaged resources in Windows Forms programming that is unclear to me. In C++, if you loaded an icon resource using "ExtractIcon()", the resource was...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
7
by: Ioannis Vranos | last post by:
I have been checking C++/CLI lately by using VC++ 2005 Express Beta 1 (should be called Alpha though). In managed extensions we could pass managed pointers to functions taking unmanaged pointers...
7
by: Ken Varn | last post by:
I am working in managed C++. I have a Mutex object in which I need to replace the Handle property with a new handle. The new handle is being constructed using Win32 CreateMutex call. I need to...
1
by: Steve N. | last post by:
I'm having trouble getting a handle returned from the following code within a managed class: HANDLE m_hSerialComm = CreateFile("\\\\.\\COM1\0\0\0", GENERIC_READ|GENERIC_WRITE, 0, 0,...
5
by: Sam777 | last post by:
I was under the impression that creating the app_offline.htm file at the root of the webapp would cause all handles to be closed so that the app could be removed. Unfortunately, this isn't the...
8
by: Shawn B. | last post by:
Greetings, Me again. I have (roughly) the following code: HANDLE hConsoleOutput; HANDLE hConsoleInput;
6
by: Vincent Finn | last post by:
Hi, I have what I thought was a simple question but I can't find an answer. I need to access (create) unmanaged C++ classes in C#. They aren't COM and they aren't struct just simple classes. ...
16
by: ink | last post by:
Hi all, If I have a Windows 32 pointer to and object (Handle) and I know what that object is (Button) can I some how cast that pointer to a type of System.Windows.Forms.Button and then use its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.