472,333 Members | 1,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

using System.IntPtr

I need to get a pointer of a variable...
How can I get it ?

for example:
Dim a() as CStructure
Dim z as System.IntPtr

z = ??????

Sushi
Nov 21 '05 #1
6 22364
The Marshal class has methods to help in this.

See Marshal.UnsafeAddressOfPinnedArrayElement.

You can create and use unmananged blocks of memory with Marshal.AllocHGlobal
and it's related methods

Vou can copy to and from C structs with StructureToPtr and PtrToStructure.

HTH

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@hotmail.com> wrote in message
news:e7**************@TK2MSFTNGP14.phx.gbl...
I need to get a pointer of a variable...
How can I get it ?

for example:
Dim a() as CStructure
Dim z as System.IntPtr

z = ??????

Sushi

Nov 21 '05 #2
"Sushi" <su********@hotmail.com> schrieb:
I need to get a pointer of a variable...
Variables that are declared as a reference type are "type-safe pointers":

\\\
Dim f1 As New Foo()
Dim f2 As Foo = f1 ' Points to the same instance as 'f1'.
///
How can I get it ?

for example:
Dim a() as CStructure
Dim z as System.IntPtr


What exactly do you want to archieve/to do with the pointer?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGetAppData.GetApps(ByRef nApps As System.UInt32, ByVal aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CAppData

In another words...
pAppData() As COMSVCSLib.CAppData
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the pAppData
array
Did you understand me ?

Thanks for all,
Sushi
Nov 21 '05 #4
You need to declare a VB structure that corresponds to the layout of the C
structure that you are passed from the unmanaged side. Once you have that
you can use Marshal.PtrToStructure to obtain the contents of your structure.
For an array of structures you need to modify the IntPtr that you have to
the offset of the particular array element that you wish to access.

Unfortunately I can't find a reference to the structure you're trying to
grab.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@terra.com.br> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGetAppData.GetApps(ByRef nApps As System.UInt32, ByVal
aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CAppData

In another words...
pAppData() As COMSVCSLib.CAppData
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the
pAppData
array
Did you understand me ?

Thanks for all,
Sushi

Nov 21 '05 #5
I'm sure that if you can obtain this book it will be useful...

http://www.webtropy.com/articles/art...rop=COMSVCSLib

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@terra.com.br> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGetAppData.GetApps(ByRef nApps As System.UInt32, ByVal
aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CAppData

In another words...
pAppData() As COMSVCSLib.CAppData
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the
pAppData
array
Did you understand me ?

Thanks for all,
Sushi

Nov 21 '05 #6
thanks... I will try to create a structure in vb.net...

the reference is COMSVCSLib...
I already saw this article... but it's doesn't help me more than the object
browser for COMSVCS :-))))

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'm sure that if you can obtain this book it will be useful...

http://www.webtropy.com/articles/art...rop=COMSVCSLib

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@terra.com.br> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGetAppData.GetApps(ByRef nApps As System.UInt32, ByVal
aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CAppData

In another words...
pAppData() As COMSVCSLib.CAppData
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the
pAppData
array
Did you understand me ?

Thanks for all,
Sushi


Nov 21 '05 #7

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

Similar topics

1
by: C | last post by:
Hi, I have a C# Web Application. I am Referencing System.Web In teh code behind of one of my pages I have below imports- using...
4
by: Daisy | last post by:
Having a weird problem... Just moving some code into new classes & methods. Originally, I created a new instance of "Game" (my form), and it...
2
by: ScOe | last post by:
I have directx namespace which contains few class-es (dx wrapper) Direct3d.Device expect System.IntPtr in passed parameters. When using it in main...
4
by: marcelino | last post by:
Hi, I have c# express beta I try to write the following using clause: System.Runtime.Remoting.Channels.Http; because I want to create a...
4
by: Manuel Costa | last post by:
How the hell do i convert System::IntPtr to HDC? manuel
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly...
9
by: garyusenet | last post by:
I am using a C# solution that somebody kindly sent me. It was a console application. I am trying to get use of the MessageBox. I have added...
11
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and...
2
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.