473,758 Members | 4,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

marshaling the System::Guid structure

I've been wrapping an unmanaged class, and everything has gone well. That
is...until now.

I've hit a wall while trying to marshal the System::Guid type down into the
unmanaged GUID structure that the unmanaged class asks for. For some
reason, none of my attempts to date have met with success. Maybe someone
else has an idea how this works?

Lee
Nov 17 '05 #1
2 3043
Guid^ g = gcnew Guid ("B6806700-E2B1-4022-9D4B-B0205CB37935");
array<System::B yte>^ a = g->ToByteArray( );
_GUID guid;
Marshal::Copy(a , 0, IntPtr(&guid), a->Length);

Note, I'm using VS 2005.

Brian

"Lee Crabtree" <lc*******@gois i.com> wrote in message
news:uu******** ******@tk2msftn gp13.phx.gbl...
I've been wrapping an unmanaged class, and everything has gone well. That
is...until now.

I've hit a wall while trying to marshal the System::Guid type down into
the unmanaged GUID structure that the unmanaged class asks for. For some
reason, none of my attempts to date have met with success. Maybe someone
else has an idea how this works?

Lee

Nov 17 '05 #2
I had to change this some, probably because I'm not using 2005 yet. I wound
up doing this:

char * guidData = static_cast<cha r*>(const_cast< void*>(static_c ast<const
void*>(Marshal: :StringToHGloba lAnsi(Convert:: ToString(guid.T oByteArray()))) ));

void __pin *data = &(guidData[0]);

Everything seems to be working. Thanks for the jump-start.

Lee

"Brian Muth" <bm***@mvps.org > wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l...
Guid^ g = gcnew Guid ("B6806700-E2B1-4022-9D4B-B0205CB37935");
array<System::B yte>^ a = g->ToByteArray( );
_GUID guid;
Marshal::Copy(a , 0, IntPtr(&guid), a->Length);

Note, I'm using VS 2005.

Brian

"Lee Crabtree" <lc*******@gois i.com> wrote in message
news:uu******** ******@tk2msftn gp13.phx.gbl...
I've been wrapping an unmanaged class, and everything has gone well.
That is...until now.

I've hit a wall while trying to marshal the System::Guid type down into
the unmanaged GUID structure that the unmanaged class asks for. For some
reason, none of my attempts to date have met with success. Maybe someone
else has an idea how this works?

Lee


Nov 17 '05 #3

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

Similar topics

2
1917
by: crawfordn | last post by:
Hi there, I'm trying to utilize the WSUS API to create my own custom reporting agents. I'm using iUpdateServer.GetComputerTargetGroup, which is defined as follows: Public Function GetComputerTargetGroup( _ ByVal id As Guid _ ) As IComputerTargetGroup
7
10790
by: headware | last post by:
Is the GUID generated by the .NET System.Guid.NewGuid() function compatible with Access' Replication ID field type? Dave
0
1281
by: dwivedialok13 | last post by:
I have a structure in managed code (c#) which I want to access from COM. public struct DI_DOCUMENT { public int idDocument; public Guid udi ; public ENM_DI_DOCUMENT_TYPE enmDocType; public short iDataFormat; public string bstrIndexParams;
5
6340
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of uniqueidentifier, originally taken from objectGUID from active directory domain)
5
6501
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the following error: System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Web.Services.Protocols.HttpServerType..ctor(Type type) at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
1
2018
by: Jeff | last post by:
ASP.NET 2.0 In the code below, the reader has a column named "Id". The MsgInfo class needs that value sent into its constructor. But MsgInfo need it as a System.Guid datatype. How do I convert this "Id" value to System.Guid datatype?? protected virtual MsgInfo ReadMessage(IDataReader reader) { return new MsgInfo(System.Guid(reader) <.---- this code crashes
1
5725
by: Jeff | last post by:
ASP.NET 2.0 This problem occur using the basic version of SQL Server 2005 which get installed when installing Visual Studio 2005! I have inserted a record in the Test table. But when I try to insert a second record I get this error: {"Violation of PRIMARY KEY constraint 'PK_Test'. Cannot insert duplicate key in object 'dbo.Test'.
2
23969
by: Jeff | last post by:
ASP.NET 2.0 I have a GridView on my webpage. As one of its columns I've put a HiddenField into a TemplateField. The porpose of this HiddenField is to hold the ID of the row. Each row in the GridView shows a purchase order. This ID column shows the ID of the purchase order. So if the user wants to delete this purchase order then the value in the HiddenField is sent into a stored procedure and updates the database.... So that's why I...
2
12029
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to convert a string into a System.Guid! I have this code where I want to use the convert: Message.DeleteMessage(hidden.Value);. Here DeleteMessage wants an argument of type System.Guid, but the hidden.Value (HiddenField) has stored it as a string. I need to convert the value of hidden.Value to a System.Guid for this to compile, but how??
0
9298
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9737
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
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 we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.